5 ms·
1. Please keep getting carried away 2. I completely didn't understand how a functor can make a list. Note, to me, a functor is a C++ class that overrides opera
by skrebbel 12y ago
1. Please keep getting carried away
2. I completely didn't understand how a functor can make a list. Note, to me, a functor is a C++ class that overrides operator(). I loved how your writeup allowed me to understand Cosmos concepts _without_ learning Prolog, so an introduction to functors (maybe a later blog post?) would be warmly appreciated :-)
- tomp 12y agoTo me, a functor is a ML function from modules to modules :)
- tempodox 12y agoYes, C++ is notorious for abusing the “functor” concept in the way you mention. Compare the Wikipedia article: http://en.wikipedia.org/wiki/Functor http://en.wikipedia.org/wiki/Functor A better way to describe a class that defines the »operator apply« is “function object”, as it is called in Lisp.
- abathologist 12y agoWhat the designer calls "functors" just appear to be positional records (or labeled tuples). In Lisp, a list is a series of nested pairs with an empty list as the last element: `(a . (b . ())`. The data structures the designer calls "functors" are just labeled pairs. The Lisp empty list, `()`, is the Cosmos term `Cons`, the Lisp pair `(a . ())` is the Cosmos compound term `Cons(a, Cons)`.