Having taken an incredibly shallow look at the first few pages of SICM, I will 
now highly recommend to you the conjunction

T=: 2 : '] , u d. (i.<:n)'

where (u T n) gives the first n components of the "local tuple" of the function 
u. It may then be applied to a time t to obtain the actual value of this 
vector. So:

   *: T 4
] , (*: , +: , 2"0)"0

For the record, I am not entirely sure how this works with vector outputs (or 
inputs, but these seem less important).

Marshall

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Alex Gian
Sent: Thursday, December 09, 2010 7:53 PM
To: Programming forum
Subject: [Jprogramming] Verbs that take verbs as arguments (pt 2)

Sorry to plague you with more newbie questions, but I'm a little pressed for 
time here.

OK, for anyone familiar with Scheme/Lisp/λ-calculus etc, here's what I'm trying 
to do:

(define (gamma q)
  (lambda(t)
    (list t (q t) ((d1 q) t)))


In other words, I want to pass a monadic verb (call it 'q') to the 'gamma' 
verb/function  and I want the result to be a monadic verb/function that will 
accept a value ('t') and return a three elem array of rank 1 t, q t, q D.1 t

IOW, something like
testfunc =. gamma @ q
testfunc 1.1
  1.1 (q 1.1) ((q D.1) 1.1)

(In case anyone wonders why the weird questions, I am working through Sussman & 
Wisdom's SICM, and would like to try the code in parallel in J to compare the 
two notations.)

I suppose I am really trying to figure how J deals with anonymous functions.  
Where I am getting stuck is the scoping of the values of y (and x) in explicit 
definitions.

I /could/ do it as a dyad, but
gamma=: dyad : 'y,(x y),x D.1 y'
doesn't seem to work for me either, and I really would prefer monadic, kinda 
seeing how "currying" maps to J.






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

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

Reply via email to