Apologies for the lame noob query again, but I've already been through a
few pages of scribblings and unsuccessful attempts.
I've also read and followed Chris Burke's "Elegant Program - #~1:=...@q:"
which deals with a similar theme, and searched the site without much to
show for it.  Also tried using the "13 :" cheat, no joy there, either.

Basically I want a pretty bog standard filter function, textbook h.o.p.
example as given in the Lisp family, but obviously in J tacit style, not
recursive.  Say the left argument will be a boolean function and the
right arg the string to filter.
So, e.g.

odd =: 2&|

NB. This is OK
(odd i.9) # i.9
   1 3 5 7

NB. but if I try to make "filter" a function, somehow along the lines
NB. This definitely does NOT work
filter =: ([]) # ]
odd filter i.9
   1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0

The above is one of the less bizarre of my attempts.   Seems to have
inverted left and right, gawdknowswhy.
What am I doing wrong?

I have to say, that as an interested and eager newcomer, the hurdles for
such basic, almost calculator-like functionality - take for granted in
any modern language - are the biggest turn-off.

Perhaps when I've got my head around it, I could write up a little "lame
noob's" guide. 
Yes, dot product and matrix multiplication will also feature in it!
Perhaps a simple file (loadable by default) implementing such functions
would be useful to other newcomers.  Just my 2¢

At the moment J feels not so much like an array language, but like an
assembler for an array system.  :D



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

Reply via email to