Marc Simpson also mentioned http://www.catonmat.net/blog/on-functors/

This describes how the term "functor" means different things in the
context of different languages.

And, since the earlier reference was discussing ocaml implementations,
I think we can assume that my first post was focusing on the ML
meaning of functor.

And, some of the later posts in this thread have been focusing on the
Haskell definition of functor.

But, are these two concepts really all that different, from a J perspective?

I am thinking: maybe not.

Let's consider
   tree=. 'appel';<'peer';'pruim'
from Aai's post.

Here, we wound up using L:0 to implement our fmap.  But we have other
ways of representing tree structures in J.  One I am fond of is: list
of parent node indices.  Here, this data structure might look like:

   parents=. _ 0 0 2 2
   data=. 'appel';'peer';'pruim'
   tree=: data; parents

Now we do not have a trivial pretty display mechanism, but we
trivially gain the ability to have boxed data at our leaves.

Now, our structure preserving fmap might look like this:
   fmap=: (&.>)(&.>)(@{.)(@])(`0:)(`])}~
   # fmap tree
┌───────┬─────────┐
│┌─┬─┬─┐│_ 0 0 2 2│
││5│4│5││         │
│└─┴─┴─┘│         │
└───────┴─────────┘

It's doing data selection again -- though, granted, the data being
selected is hardcoded instead of being parameterized.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to