Marshall Lochbaum wrote:
>
> 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).
>
It works fine for vector arguments.
Let's rework it first to fit the sought gamma:
Gamma =: (d.0 1)(]`,`)(`:6)("0)
*: Gamma
(] , (*: , +:)"0)"0
*: Gamma i.10
0 0 0
1 1 2
2 4 4
3 9 6
4 16 8
5 25 10
6 36 12
7 49 14
8 64 16
9 81 18
For vector q=.*:,+:,<:
(*:,+:,<:) Gamma i.10
0 0 0 _1 0 2 1
1 1 2 0 2 2 1
2 4 4 1 4 2 1
3 9 6 2 6 2 1
4 16 8 3 8 2 1
5 25 10 4 10 2 1
6 36 12 5 12 2 1
7 49 14 6 14 2 1
8 64 16 7 16 2 1
9 81 18 8 18 2 1
>
> -----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
>
--
View this message in context:
http://old.nabble.com/-%3A-on-integer-of-internal-complex-type-tp30403330s24193p30425359.html
Sent from the J Programming mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm