I've got my own opinions about these kinds of topics as pedagogical devices, so maybe best not to get me started on this topic. (-:
I've got my own opinions about these kinds of topics as pedagogical devices, so maybe best not to get me started on this topic. (-:
Happy to hear them, especially since I basically built this variation of Turtle to teach, inspire, and peel back layers of the universe. ( Also, in case this isn't clear, if you work on a language you end up a language nerd ) Please share your opinions, I'm eager to hear them.
parentheticallyspeaking.org/articles/how...
Btw, if you want a real recursive head trip, do you know of any other language that allows anonymous recursion? It's one of the more fun little lambdas to bust out in #PowerShell. I still haven't seen that feature anywhere else, but my knowledge is finite. 😉. You seen it anywhere ?
I'm not sure what "anonymous recursion" means really, but the Y-combinator might be what you're looking for, and it's encodable in numerous languages directly or with a little bit of effort (depending on eager vs lazy evaluation, the specific type structure of the language, etc.).
Hmm. I suppose one way to think of it would be in terms of a "automatic" y-combinator. & $myinvocation.MyCommand.ScriptBlock # brief anonymous recursion example. Let's me build a recursive lambda without ever saving it to a variable. ( $myInvocation is an automatic variable )
Is this the sort of thing you mean? Note that there is no recursive name reference. I've also purposely created an outer function so we can confirm the two instances (non-rec-lucas and non-rec-fib) are not confused with each other, i.e., they really are from this *invocation*.
Looks like it. What language is that? (looks vaguely functional, but I don't think it's scheme)
But if that's what it is, then it's certainly not a Y-combinator! It's just an anaphoric name binding. (Which is very easy to implement if you have a reasonably powerful macro system with the right primitives.)
Cool! I've run across Racket but haven't used it much, or deeply integrated it for automagic interpretation just yet. Will add it to the "to-do" list. PowerShell is deeply influenced by functional languages. I would not at all be surprised if this is where $myInvocation came from. Will ask.
Btw, I put the code and some more examples up in this repo. Please let me know if I should credit you differently. Thanks. github.com/shriram/anon...
MIT Scheme (and probably other Lisps before it) had a variant of `lambda` where you could slip in a name before the argument list, and it automatically created a recursive binding. That is a very handy feature, and seems nicer than this slightly clunkier fixed name…
Good article. Recursion is a tricky topic to teach and explain. FWIW, the Turtle I linked to doesn't use it ( yet ), as the object pipeline helps avoid it. If I were looking for a practical example to teach, I would probably try for serialization ( for example, converting objects to css ).