http://blog.0branch.com/implementing-functor-in-ocaml

"A Functor is (somewhat informally): a structure that provides a
mapping operation that applies to a value in a given context,
preserving that context."

In other words, this is probably an example of a functor:

   A=: 2 3 5 7 11 13
   F=: *:

   (0 0 1 0 0 0 * F A) + A * 1 1 0 1 1 1
2 3 25 7 11 13

We could also use merge, and specify the target to be updated using indices:

   2 F@{`[`]} A
2 3 25 7 11 13

(A meaningful J expression with both curly braces and square brackets
being "balanced"... this seems almost misleading.)

Also, hypothetically, if we have names for our data elements, we can
specify the elements to be updated by name.  Names might be nouns
(roughly equivalent to selection vectors or indices) or verbs pairs
(one to extract the value and a related name to put the result back in
its place -- bonus points if these are obverses of each other) or
adverbs (modifying a verb so that it gets applied to the right data
and leaves the rest alone).  Adverbs are probably closest to
"functors" in the sense of the reference I posted at the top, though
they are not always the most useful way of encapsulating this
information.

Anyways, this struck me as related to an ongoing pattern I have seen
discussed in these forums, so I thought I'd post about it and invite
you all to post your favorite related concepts.

Thanks,

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

Reply via email to