On Mon, March 19, 2012 2:29 am, Linda Alvord wrote: > It may help if you think of the problem more as a math problem: > > load 'plot' > x=:i:5 > x > _5 _4 _3 _2 _1 0 1 2 3 4 5 > plot y=:x^2
To show the correct x values, that would be plot (;*:)x NB. Hook > x is the data like "banana" is data, and it is a "noun". > > f=:x^2 or y=:x^2 is a "verb" which tell what to do with the "noun". > Similarly you can say "eat the banana" or "cook the banana". > > Looking at J as a way to create arrays of data and then process that > data > to get what you want as an answer may keep you from getting too caught up > in language issues. > > Linda > > ---=--Original Message----- > From: programming-boun...@jsoftware.com > [mailto:programming-boun...@jsoftware.com] On Behalf Of Kim Kuen Tang > Sent: Monday, August 15, 2011 5:09 AM > To: programming@jsoftware.com > Subject: [Jprogramming] Several questions about j > > > Hi everyone, > > here are some newbie questions regarding the differences between j and > kdb. > > Are verbs ( dyad or monad) first-class citizen in j? Yes, as are ambivalent verbs. > Is it possible to forward a verb to another verb? It is possible to apply an adverb or conjunction to a verb, as in v/ or v"0. > Is it possible to box a verb into list ? That would be a gerund; yes. However, it is not possible to box a verb directly. The expression <v makes a hook. For example, < >. is the query, Is y less than its ceiling? That is, Is y not an integer? < >. y y< >.y However, >.`'' works, producing ┌──┐ │>.│ └──┘ > Is it possible to have a dictionary like the case in kdb? Something like > : > (`a`b`c)!(1 2 3) A search leads to http://code.kx.com/wiki/Startingkdbplus/qlanguage#2.6_Introductory_Examples q)dict:`items`sales`prices!(items;sales;prices) q)dict items | nut bolt cam cog sales | 6 8 0 3 prices| 10 20 15 20 So, in J: items=.;:' nut bolt cam cog' sales=.<"0 (6 8 0 3) prices=.<"0 (10 20 15 20) ]dict=.('items';'sales';'prices'),. items,sales,:prices ┌──────┬───┬────┬───┬───┐ │items │nut│bolt│cam│cog│ ├──────┼───┼────┼───┼───┤ │sales │6 │8 │0 │3 │ ├──────┼───┼────┼───┼───┤ │prices│10 │20 │15 │20 │ └──────┴───┴────┴───┴───┘ Is that what you were looking for? > What i want to do in j is to program a verb (i will call it p) that will > accept a monad and output a plot of this monad. That would be an adverb. > For example: > > f=. 3: 0 'y^2' > p=. (implementation) > > p f will output the plot of f between -5 and 5. f=.*: p=.1 : 'plot@(i: ; (u@i:))' f p 5 (graph) I have provided a number of examples of such constructions for function tables, together with exercises, in my J translation of Iverson's Algebra: An Algorithmic Treatment, at http://booki.treehouse.su/algebra-an-algorithmic-treatment/ > Thanks for any comments and answers. You are very welcome. > Regards, > > Kim -- Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://wiki.sugarlabs.org/go/Replacing_Textbooks ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm