osdir.com
mailing list archive

Subject: Re: J for functional programmers - msg#00079

List: lang.j.general

Date: Prev Next Index Thread: Prev Next Index
dly wrote:
> I believe there is probably a good reason why J does not map this
> function to the verb / and does map it to # but right now I cannot tell
> what that reason would be. If someone knows and would like to enlighten
> me I would appreciate it and feel free to mock me for being so dense
> while you are about it.

APL uses / as both a function and an operator. This is a mistake, and
for example, leads to problems when using / in function composition. I
don't have an APL interpreter to hand, but seem to remember that you
could not do something like "boolean / each boxed_list", for this reason.

The J # is similar to the APL function /, while J / is similar to the
APL operator /.



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: J for functional programmers

Yes this appears to be what I need. I think in APL I used / in this way but for some reason 1 0 1 0 1 / 'abcde' |domain error | 1 0 1 0 1/'abcde' 1 0 1 0 1 / 'abcde' |domain error | 1 0 1 0 1/'abcde' 1 0 1 0 1 / 'abcde' |domain error | 1 0 1 0 1/'abcde' 1 1 0 0 1/i. 5 |domain error | 1 1 0 0 1/i.5 1 1 0 1 1# 'abcde' abde 1 0 1 0 1# i. 5 0 2 4 If there is a hint about this in the Volcabulary, somehow I missed it. I expected that to be the easiest place to find out what a particular symbol as used for but apparently not--here is the entry: # Tally • Copy #. Base 2 • Base #: Antibase 2 • Antibase If the arguments have an equal number of items, then x#y copies +/x items from y, with i{x repetitions of item i{y . Otherwise, if one is an atom it is repeated to make the item count of the arguments equal. The complex left argument a j. b copies a items followed by b fills. The fit conjunction provides specified fills, as in #!.f . I believe there is probably a good reason why J does not map this function to the verb / and does map it to # but right now I cannot tell what that reason would be. If someone knows and would like to enlighten me I would appreciate it and feel free to mock me for being so dense while you are about it. Thanks Donna On Sat 7/Oct/2006, at 7:38 PM, Dan Bron wrote: I don't know what you mean, but filtering and selection can be accomplished in many ways in J. The most fundamental, in my opinion, is # . To wit: ] some_numbers =. 5 ? 10 2 7 1 9 5 greater_than_4 =. 4 < ] ] mask =. greater_than_4 some_numbers 0 1 0 1 1 mask # some_numbers 7 9 5 (#~ 4 < ]) some_numbers 7 9 5 Here, mask was a boolean list which indicated which elements of some_numbers to keep and which to discard. That is, told # which elements to filter. My mnemonic for was (when I started), that # looks like a little net or sieve. When you put things in a net, you lose whatever lies over a hole, and you keep everything else. In a boolean list, the 0s (little circles, absences) are the holes, and the 1s the lines (presences), which together make up the net. -Dan

Next Message by Date: click to view message preview

Re: J for functional programmers

I Prefer using the definition select=: 1 : 'u # ]' instead of your hook below. I find it much easier crafting compound conditions (for example >4 and <8) 4&< select some_numbers 5 7 9 (8&> *. 4&<) select some_numbers 5 7 seeing a select statement in a sentence also helps me realize what its doing in a way that # wouldn't because it is more vague, and its position in a train is less recognizable. Also, 4 verb trains make this way to filter a bit daunting on beginers, I think the adverb version is just much easier. ----- Original Message ---- From: Dan Bron <jf-pk/dOXfYWDBeoWH0uzbU5w@xxxxxxxxxxxxxxxx> (#~ 4 < ]) some_numbers 7 9 5

Previous Message by Thread: click to view message preview

Re: J for functional programmers

Yes this appears to be what I need. I think in APL I used / in this way but for some reason 1 0 1 0 1 / 'abcde' |domain error | 1 0 1 0 1/'abcde' 1 0 1 0 1 / 'abcde' |domain error | 1 0 1 0 1/'abcde' 1 0 1 0 1 / 'abcde' |domain error | 1 0 1 0 1/'abcde' 1 1 0 0 1/i. 5 |domain error | 1 1 0 0 1/i.5 1 1 0 1 1# 'abcde' abde 1 0 1 0 1# i. 5 0 2 4 If there is a hint about this in the Volcabulary, somehow I missed it. I expected that to be the easiest place to find out what a particular symbol as used for but apparently not--here is the entry: # Tally • Copy #. Base 2 • Base #: Antibase 2 • Antibase If the arguments have an equal number of items, then x#y copies +/x items from y, with i{x repetitions of item i{y . Otherwise, if one is an atom it is repeated to make the item count of the arguments equal. The complex left argument a j. b copies a items followed by b fills. The fit conjunction provides specified fills, as in #!.f . I believe there is probably a good reason why J does not map this function to the verb / and does map it to # but right now I cannot tell what that reason would be. If someone knows and would like to enlighten me I would appreciate it and feel free to mock me for being so dense while you are about it. Thanks Donna On Sat 7/Oct/2006, at 7:38 PM, Dan Bron wrote: I don't know what you mean, but filtering and selection can be accomplished in many ways in J. The most fundamental, in my opinion, is # . To wit: ] some_numbers =. 5 ? 10 2 7 1 9 5 greater_than_4 =. 4 < ] ] mask =. greater_than_4 some_numbers 0 1 0 1 1 mask # some_numbers 7 9 5 (#~ 4 < ]) some_numbers 7 9 5 Here, mask was a boolean list which indicated which elements of some_numbers to keep and which to discard. That is, told # which elements to filter. My mnemonic for was (when I started), that # looks like a little net or sieve. When you put things in a net, you lose whatever lies over a hole, and you keep everything else. In a boolean list, the 0s (little circles, absences) are the holes, and the 1s the lines (presences), which together make up the net. -Dan

Next Message by Thread: click to view message preview

Re: J for functional programmers

I Prefer using the definition select=: 1 : 'u # ]' instead of your hook below. I find it much easier crafting compound conditions (for example >4 and <8) 4&< select some_numbers 5 7 9 (8&> *. 4&<) select some_numbers 5 7 seeing a select statement in a sentence also helps me realize what its doing in a way that # wouldn't because it is more vague, and its position in a train is less recognizable. Also, 4 verb trains make this way to filter a bit daunting on beginers, I think the adverb version is just much easier. ----- Original Message ---- From: Dan Bron <jf-pk/dOXfYWDBeoWH0uzbU5w@xxxxxxxxxxxxxxxx> (#~ 4 < ]) some_numbers 7 9 5
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by