Johann Hibschman wrote:
> Part of the problem here is that filter is not a verb; it's an *adverb*.
That's the key insight one needs, yes.
> I'm just a beginner myself, so I'm not sure that this can't be done
> tacitly, but an explicit version is:
> filter =: 1 : '#~ x'
Some beginner advice here.
The "x" is ambigous in two regards:
(a) could be used for verb or noun arguments, i.e. "filter"
can be used both as "adnoun" as "adverb". (I guess you
weren't even aware of that.)
(b) As soon as you *do* refer to u/v/m/n placeholders, too, the
x/y placeholders switch their meaning to refer to effective
arguments of the created verb.
Write
filter =: 1 : '#~ u'
to make explicit that you are defining an adVERB here
(and get the runtime checks to ensure this).
Write
filter =: 1 : '(#~ u) y'
to make explicit that you are defining an adverb here
to create MONADIC verbs (and get the runtime checks
to ensure this).
Martin Neitzel
PS: Having said all this, here comes a (non-beginner!) quiz:
filter =. 1 : '#~ x' NB. as orginally written
mystery =. 1 0 2 filter NB. as per (a).
Without trying it out:
What is mystery and how can you use it?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm