First time coding in PHP and I hate it. It's an inconsistent clusterfuck.
1+"1" is ok and returns int but "str"+"str" is an error and you have to use . and if you do "1"+"1" it's ok and turns into an int
There are also multiple ways to do the same. To convert a number to a string you can either cast it or use use strval()![]()
@Shlomo Yeah, that doesn't look fun
@matrix I’m afraid @Shlomo is well named, this is a terrible problem to try to demonstrate code for any language, and what we can see of the example code it is also bad.
Fizz buzz this is not, it’s trying to compute “a member of a family of related integer sequences defined by non-linear recurrence relations,” a https://en.wikipedia.org/wiki/Hofstadter_sequence
Then the code isn’t even properly formatted: compare the first and second if’s, the second is correct, vertically aligning the test and true and false return values. If you don’t use a minimally smart editor or in the bad old days a coding form before it’s punched to cards you’re in for a world of hurt.
On the other hand it’s interesting in that lambda creates a function to use later in the code, and letrec gives the functions names to keep the global namespace clean. Otherwise you could create both using define outside of the function that’s being defined. Being able to create functions on the fly, making them “first-class” so they can be used as arguments to other functions and returned by them, is very powerful. For a much more limited example, see the classic qsort in the C standard library: https://en.wikipedia.org/wiki/Qsort
Then there’s not enough code to comment on especially since it’s too late in the day for me to even think about anything pertaining to sequences other than learning “The On-Line Encyclopedia of Integer Sequences® (OEIS®)” exists: https://oeis.org/ And close with what per Wikiquote is a bogus quote from Abraham Lincoln which I first read in a Scheme paper: “People who like this sort of thing will find this the sort of thing they like.” Sequences for their own sake never interested me, but you can use them to do cool things.