KKT> here are some newbie questions regarding the differences between j and kdb.
Caveat: I just know some crude basics of K and nothing of kdb.
KKT> Are verbs ( dyad or monad) first-class citizen in j?
Yes, in the sense that they are values which can be assigned to names
and passed as arguments to higher-order functions (called "adverbs" and
"conjunctions" in J).
KKT> Is it possible to forward a verb to another verb?
I'm not sure what you mean be "forwarding", but:
- many conjunctions will compose two verbs (in different ways), say:
f@:g y is equivalent to (f g y). @ @: & &: are four conjunctions
who all do a similiar function composition, but differ in their
treatment of ranks and ambivalence.
- f g h y will work the same in K and J.
- (f g h) y will trigger a different function composition in J ("hook").
KKT> Is it possible to box a verb into list ?
Yes, +`-`f`g yield a vector of four verb representations (data).
KKT> Is it possible to have a dictionary like the case in kdb? Something
KKT> like : (`a`b`c)!(1 2 3)
As far as I'm aware, J doesn't have K*-style dictionaries.
They have been thought of, though: the test suite coming with the
J sources has a few tests that J's indexing verb From ({) may one
day accept arbitrary data as keys into a two-column boxed array.
(The tests have been there for quite some time -- I wouldn't hold
my breath.)
KKT> What i want to do in j is to program a verb (i will call it p) that will
KKT> accept a monad and output a plot of this monad.
The construct in J "accepting a monad" is an adverb. The monad verb will
be its LEFT argument. The result of (verb adverb) will be another verb;
this will eventually be called with noun arguments. Thus:
sample_monad =: square =: *:
(sample_monad p) _2 _1 0 1 2 NB. parens redundant
require 'plot' will give you a nice "plot" verb. I won't spoil you
with giving any hints how to define "p". It's a nice exercise.
Martin
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm