[: v1 v2 is a special form for fork.

And there are differences between v1@v2 and [: v1 v2

One obvious difference is the syntax.  But another difference is rank.
 These define verbs with equivalent meaning:

V=:   v1@v2
V=:   ([: v1 v2)"v2

And, these are equivalent:

W=:   v1@(v2"_)
W=:   [: v1 v2

And, yes, nested explicit forms can be clumsy.  That said, they can be
achieved in other ways.  For example:

VV=: 3 :0
   3 :'whatever'
   ...
)

And you can also use adverbs or conjunctions to achieve this.  The
parser processes tokens from right to left, and the n :0 forms take
effect as the are parsed.  So:


VVVV=: (3 :0) (2 :0) (3 :0)
   rightmost definition
   something=: 3 :'something else...'
   ...
)
   middle definition
   u will be leftmost definition
   v will be rightmost definition
   ...
)
   leftmost definition
   ...
)

Anyways, this sort of thing is doable.  But a relevant question is:
why would you do this?

The distinction between explicit and tacit definitions is that
explicit definitions use names to refer to values they are working
with.  And the natural way of composing explicit definitions involves
naming your verbs (or other modules).

Using names also gives you an opportunity to incorporate some
documentation and hints into your code.

-- 
Raul


On Thu, Mar 22, 2012 at 4:03 AM, Alexander Epifanov <[email protected]> wrote:
> Just some notes for me after first mail:
>
> [: - cool thing, but I do not understand if it is possible to
> implement such function in haskell. Is it special form?
>
> n v v - special form, that is why 3=# works :)
>
> I wrote "find 3 unique digit numbers" with [:
> (]#~([:(3=#*.[:*./~:)":)"0) ns
>
> Looks good, and it is easier than @, because there are much less brackets.
> but if I understand correct where no different between @ and fork with [: .
> That is why there are two ways to write the same things, hard to
> decide which is better?
>
> If I understand correct, it is possible to write in explicit style
> with 3 : '' only, which inverynot easy, something like 3 :'3 :''3
> :'''y'''": y''"0 y' ns. That is why most of the time it is not correct
> style for J.
>
> Regards,
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to