Hi Bill,

Perfect!  I was unaware of the dyadic case for head.

Also, & &: @ @:  *still* don't come naturally to me.

About _. -- I'm being very careful with it. It comes back as NaN in C# which
is sometimes convenient, and mostly it behaves better than __ from what I
can see (can't find any boundary cases right now).  I'm going to use it
sparingly. Is there a performance hit? What are your reservations?

thanks,
-Steven


On 11 December 2010 10:57, <[email protected]> wrote:

> Send Programming mailing list submissions to
>        [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://jsoftware.com/cgi-bin/mailman/listinfo/programming
> or, via email, send a message with subject or body 'help' to
>        [email protected]
>
> You can reach the person managing the list at
>        [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Programming digest..."
>
>
> Today's Topics:
>
>   1. Sudoku solution query (Robert Goudie)
>   2. Re: Sudoku solution query (bill lam)
>   3. auto fill with something other than zero? (Steven Taylor)
>   4. Re: auto fill with something other than zero? (Steven Taylor)
>   5. Re: auto fill with something other than zero? (bill lam)
>   6. Re: Verbs that take verbs as arguments (pt 2) (Alex Gian)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 11 Dec 2010 18:40:51 +1300
> From: "Robert Goudie" <[email protected]>
> Subject: [Jprogramming] Sudoku solution query
> To: <[email protected]>
> Message-ID: <000101cb98f5$f8d020b0$ea7062...@[email protected]>
> Content-Type: text/plain;       charset="us-ascii"
>
> Hi,
>
>
>
> In the essay on Sudoku solutions at
> http://www.jsoftware.com/jwiki/Essays/Sudoku the first line
>
>
>
> j      =. (]/. i...@#) ,{;~3#i.3
>
>
>
> generates the indicies for each box.   As a relative newcomer to J I am
> trying to figure out the relationship between the matrix created by the
> expression on the LHS of the ravel (,) and the paired box values on the RHS
> of this expression.   I can "tune" the shape and contents of matrix created
> on the LHS to some degree by varying the paired values on the RHS.
>
>
>
> Could someone please clarify the relationship between the limited shaping
> of
> the matrix on the left by varying the pairs of values in the box list -
> keeping in mind I don't have all of J's nuances under the belt yet?
>
>
>
> Thanks
>
> Rob
>
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 11 Dec 2010 14:18:36 +0800
> From: bill lam <[email protected]>
> Subject: Re: [Jprogramming] Sudoku solution query
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=utf-8
>
> What does "limited shaping" mean?
>
> ???, 11 ??? 2010, Robert Goudie ?????(?):
> > Hi,
> >
> >
> >
> > In the essay on Sudoku solutions at
> > http://www.jsoftware.com/jwiki/Essays/Sudoku the first line
> >
> >
> >
> > j      =. (]/. i...@#) ,{;~3#i.3
> >
> >
> >
> > generates the indicies for each box.   As a relative newcomer to J I am
> > trying to figure out the relationship between the matrix created by the
> > expression on the LHS of the ravel (,) and the paired box values on the
> RHS
> > of this expression.   I can "tune" the shape and contents of matrix
> created
> > on the LHS to some degree by varying the paired values on the RHS.
> >
> >
> >
> > Could someone please clarify the relationship between the limited shaping
> of
> > the matrix on the left by varying the pairs of values in the box list -
> > keeping in mind I don't have all of J's nuances under the belt yet?
> >
> >
> >
> > Thanks
> >
> > Rob
> >
> >
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
>
>
> ------------------------------
>
> Message: 3
> Date: Sat, 11 Dec 2010 09:12:45 +0000
> From: Steven Taylor <[email protected]>
> Subject: [Jprogramming] auto fill with something other than zero?
> To: Programming forum <[email protected]>
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi,
>
> I like the way ,:!.f works. It's quite neat.
>
> What would be even better is if > open behaved a little like ,: does with
> it's fill conjunction.
>
>   e.g.
>   f=:_.
>   [A=:(i.3),:!.f(i.5)
> 0 1 2 _. _.
> 0 1 2  3  4
>
>   we can extend that further with
>   [A=:A,!.f(i.7)
>   (but I suppose we've got a full copy of the existing A each time if we
> were worried about performance.)
>
>   In any case, something like this just looks more elegant:
>
>   L=:(i.3);(i.5);(i.7)
>   > L
> 0 1 2 0 0 0
> 0 1 2 3 0 0
> 0 1 2 3 4 5
>
>   >!.f L
> |domain error
>
> any ideas?  I migh play with something like this later: get count, get max
> count of each boxed list. Prebuild filled array. Utilise special code form
> of ammend... but there could be a loop  :(
>
> thanks,
> -Steven
>
>
> ------------------------------
>
> Message: 4
> Date: Sat, 11 Dec 2010 10:03:34 +0000
> From: Steven Taylor <[email protected]>
> Subject: Re: [Jprogramming] auto fill with something other than zero?
> To: Programming forum <[email protected]>
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> pity that something like this wont work for the fill portion of the 2
> dimensional n-laminate .
>
>    L=:(1 1 1 _. _. _. _.),(1 1 1 1 1 _. _.),:(1 1 1 1 1 1 1)
>    A=:(i.3),(i.5),:(i.7)
>    L*A
>
> because
>   0*_.
> 0
>
> but A+L does it!
>
> Now to come up with the 1 and _. matrix based on a list of boxes.
>    B=:(1; 1 2 3; 1 2 3 4 5)
>    max=:>./ > # each B
>    ((1$~,_.$~max-)#) each B
> |domain error
> almost.  But 1$~,_. on its own works.
>
> -Steven
>
> On 11 December 2010 09:12, Steven Taylor <[email protected]> wrote:
>
> > Hi,
> >
> > I like the way ,:!.f works. It's quite neat.
> >
> > What would be even better is if > open behaved a little like ,: does with
> > it's fill conjunction.
> >
> >    e.g.
> >    f=:_.
> >    [A=:(i.3),:!.f(i.5)
> > 0 1 2 _. _.
> > 0 1 2  3  4
> >
> >    we can extend that further with
> >    [A=:A,!.f(i.7)
> >    (but I suppose we've got a full copy of the existing A each time if we
> > were worried about performance.)
> >
> >    In any case, something like this just looks more elegant:
> >
> >    L=:(i.3);(i.5);(i.7)
> >    > L
> > 0 1 2 0 0 0
> > 0 1 2 3 0 0
> > 0 1 2 3 4 5
> >
> >    >!.f L
> > |domain error
> >
> > any ideas?  I migh play with something like this later: get count, get
> max
> > count of each boxed list. Prebuild filled array. Utilise special code
> form
> > of ammend... but there could be a loop  :(
> >
> > thanks,
> > -Steven
> >
>
>
> ------------------------------
>
> Message: 5
> Date: Sat, 11 Dec 2010 18:27:05 +0800
> From: bill lam <[email protected]>
> Subject: Re: [Jprogramming] auto fill with something other than zero?
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=utf-8
>
> If I understand correctly, we want
> max=: >./ #&> B
> max&({.!._.) &> B
>
> but not sure if your really want to play with _.
>
> ???, 11 ??? 2010, Steven Taylor ?????(?):
> > pity that something like this wont work for the fill portion of the 2
> > dimensional n-laminate .
> >
> >     L=:(1 1 1 _. _. _. _.),(1 1 1 1 1 _. _.),:(1 1 1 1 1 1 1)
> >     A=:(i.3),(i.5),:(i.7)
> >     L*A
> >
> > because
> >    0*_.
> > 0
> >
> > but A+L does it!
> >
> > Now to come up with the 1 and _. matrix based on a list of boxes.
> >     B=:(1; 1 2 3; 1 2 3 4 5)
> >     max=:>./ > # each B
> >     ((1$~,_.$~max-)#) each B
> > |domain error
> > almost.  But 1$~,_. on its own works.
> >
> > -Steven
> >
> > On 11 December 2010 09:12, Steven Taylor <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > I like the way ,:!.f works. It's quite neat.
> > >
> > > What would be even better is if > open behaved a little like ,: does
> with
> > > it's fill conjunction.
> > >
> > >    e.g.
> > >    f=:_.
> > >    [A=:(i.3),:!.f(i.5)
> > > 0 1 2 _. _.
> > > 0 1 2  3  4
> > >
> > >    we can extend that further with
> > >    [A=:A,!.f(i.7)
> > >    (but I suppose we've got a full copy of the existing A each time if
> we
> > > were worried about performance.)
> > >
> > >    In any case, something like this just looks more elegant:
> > >
> > >    L=:(i.3);(i.5);(i.7)
> > >    > L
> > > 0 1 2 0 0 0
> > > 0 1 2 3 0 0
> > > 0 1 2 3 4 5
> > >
> > >    >!.f L
> > > |domain error
> > >
> > > any ideas?  I migh play with something like this later: get count, get
> max
> > > count of each boxed list. Prebuild filled array. Utilise special code
> form
> > > of ammend... but there could be a loop  :(
> > >
> > > thanks,
> > > -Steven
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
>
>
> ------------------------------
>
> Message: 6
> Date: Sat, 11 Dec 2010 10:56:52 +0000
> From: Alex Gian <[email protected]>
> Subject: Re: [Jprogramming] Verbs that take verbs as arguments (pt 2)
> To: Programming forum <[email protected]>
> Message-ID: <1292065013.11501.83.ca...@headhoncho>
> Content-Type: text/plain; charset="UTF-8"
>
> Hardly something to apologise about - I really appreciate your help!
>
> "My best attempt for up and down tuples is to represent up tuples as
> columns and down tuples as rows (and scalars as scalars)." (Marshall)
>
> ^Nice idea.  I'll mull on it.  My initial thought was to have ups just
> like normal vectors and downs as a boxed vector with a "down" prefix, in
> order to simulate SCMUTILS where up is just a normal vector, but keeping
> the option to change it in the future as SCMUTILS has done.
> Technically, then, up vectors could also (optionally) be boxed with an
> "up" prefix.
>
>  'up'; 1 2 3 4
> ????????????
> ?up?1 2 3 4?
> ????????????
>
> However, the rows/columns appraoach may be neater, since it is closer to
> the math (I think)
>
> I wonder if it would be acceptable to start a thread called SICM, to
> keep it all together and stop it from spilling over?
>
> Thanks again to everyone.
>
>
> On Fri, 2010-12-10 at 20:20 -0500, Marshall Lochbaum wrote:
> > Sorry for all the emails--I think this is the last. The final version of
> tuple utils, complete with the rotation matrix example:
> >
> >    dispu=:3 :0
> > if. 0...@$y do. ":y
> > elseif. 1=#y do. dispd {.y
> > elseif. do. '()' surround ((, ','&,)/ dispd"_1 y) end.
> > )
> >    dispd=:3 :0
> > if. 0...@$y do. ":y
> > elseif. 1=#y do. dispu {.y
> > elseif. do. '[]' surround ((, ','&,)/ dispu"_1 y) end.
> > )
> >
> >    disptuple=:' ' -.~ dispd
> >
> >    multiply=: 4 :0
> > assert. 0 0-: 2| x ,&(#...@$) y
> > if. 0 e. x ,&(#...@$) y do. x*y   NB. scalar multiplication
> > elseif. x (-:|.)&(2{.$) y      NB. contraction
> >   do. x (+/^:2 @:(multiply"_2) 1 0&|:) y
> > elseif. do. x multiply"_ _2 y  NB. non-contraction
> > end.
> > )
> >
> > NB. *****Example*****
> >
> >    disptuple rot=.(2 1 1 2$ 2 1 _1 2)
> > [(2,1),(_1,2)]
> >    disptuple r=.rot (*...@[ * |@[ o. ]) th=.0.25p1 NB. 45 degree rotation
> matrix
> > [(0.707107,0.707107),(_0.707107,0.707107)]
> >    disptuple v=.,:1 0 NB. unit vector in the x direction
> > (1,0)
> >    disptuple r multiply v
> > (0.707107,0.707107)
> >    disptuple r multiply r NB. two 45 degree rotations -> one 90 degree
> rotation
> > [(2.22045e_16,1),(_1,2.22045e_16)]
> >
> >
> > Marshall
> >
> > -----Original Message-----
> > From: Marshall Lochbaum [mailto:[email protected]]
> > Sent: Friday, December 10, 2010 7:57 PM
> > To: 'Programming forum'
> > Subject: RE: [Jprogramming] Verbs that take verbs as arguments (pt 2)
> >
> > Now I can present a rather nice tuple display that conforms with the
> standards in SICM:
> >
> >    dispu=:3 :0
> > if. 0...@$y do. ":y
> > elseif. 1=#y do. dispd {.y
> > elseif. do. '()' surround ((, ','&,)/ dispd"_1 y) end.
> > )
> >    dispd=:3 :0
> > if. 0...@$y do. ":y
> > elseif. 1=#y do. dispu {.y
> > elseif. do. '[]' surround ((, ','&,)/ dispu"_1 y) end.
> > )
> >
> >    disptuple=:dispd
> >
> > This gives:
> >
> >    u=.,:1 2 3
> >    d=.,.1 2 3
> >    s=.2
> >    disptuple@> u;d;s
> > (1,2,3)
> > [1,2,3]
> > 2
> >    disptuple u multiply u
> > ((1,2,3),(2,4,6),(3,6,9))
> >
> > You can also try
> >    disptu...@multiply&.>/~ u;d;s
> > but I would rather not post boxes in an email.
> >
> > Marshall
> >
> >
> > -----Original Message-----
> > From: Marshall Lochbaum [mailto:[email protected]]
> > Sent: Friday, December 10, 2010 7:33 PM
> > To: 'Programming forum'
> > Subject: RE: [Jprogramming] Verbs that take verbs as arguments (pt 2)
> >
> > A fully recursive version is given below:
> >
> >    multiply=:4 :0 "2
> > assert. 0 0-: 2| x ,&(#...@$) y
> > if. 0 e. x ,&(#...@$) y do. x*y
> > elseif. x ~:&(1 i. $) y do. x (+/@,@:(multiply"_2) |:) y elseif. do. x
> > multiply"_2 _ y end.
> > )
> >
> > Marshall
> >
> > -----Original Message-----
> > From: Marshall Lochbaum [mailto:[email protected]]
> > Sent: Friday, December 10, 2010 7:29 PM
> > To: 'Programming forum'
> > Subject: RE: [Jprogramming] Verbs that take verbs as arguments (pt 2)
> >
> > My best attempt for up and down tuples is to represent up tuples as
> columns and down tuples as rows (and scalars as scalars).
> > Thus an up tuple has shape (1 n) and a down tuple has shape (n 1) .
> > This gives, with many conditionals, a multiplication routine:
> >
> >    multiply=:4 :0 "2
> > assert. 0 0-: 2| x ,&(#...@$) y                  NB. reject odd ranks--these
> cannot be tuples
> > if. 0 e. x ,&(#...@$) y do. x*y                  NB. one of x or y is a
> scalar
> > elseif. x ~:&(1 i. $) y do. x (+/@,@:* |:) y  NB. up*down or down*up
> > elseif. do. x */ y end.                               NB. up*up or
> down*down
> > )
> >
> > Which gives all the correct results--try
> >
> >    u=. ,: 1 2 3
> >    d=. ,. 1 2 3
> >    s=. 2
> >    multiply&.>/ u;d;s
> >
> > One note is that this definition does not employ recursion as
> specified--it cannot handle nested tuples.
> >
> > Marshall
> >
> > -----Original Message-----
> > From: [email protected] [mailto:
> [email protected]] On Behalf Of Alex Gian
> > Sent: Friday, December 10, 2010 6:55 AM
> > To: Programming forum
> > Subject: Re: [Jprogramming] Verbs that take verbs as arguments (pt 2)
> >
> > Thanks very much for that Marshall and Raul,
> >
> > I will go over it in detail!
> >
> > BTW,
> > If any Jers want to understand Wisdom & Sussman's approach to Classical
> Mechanics, using a clear unambiguous modern functional notation (=> computer
> > executable) there is also a good introductory paper:
> > "The Role of Programming in the formulation of Ideas"
> > http://dspace.mit.edu/handle/1721.1/6707
> >
> > Also if you have got SICM, and want a brief intro into their model look
> at Chapter 8 (our notation) so that you don't have to glean the
> computational approach from reading the book.
> > http://mitpress.mit.edu/sicm/book-Z-H-79.html#%_chap_8
> >
> > Finally, what I think will be an interesting J challenge (when I get
> round to it) is the implementation of their tuples.  The text uses two types
> "up"
> > and "down" tuples, with up tuples equivalent to regular vectors, while
> down tuples correspond to duals.  There is an interesting contraction
>  possible when tuples are of the same length and opposite type.
> > You can get a taste of this from the MIT-scheme "scmutils" manual In the
> section on "Up tuples and Down tuples".
> > http://groups.csail.mit.edu/mac/users/gjs/6946/refman.txt  (about 10
> screens
> > down)
> >
> > My apologies for going a bit off-topic, but this stuff along with some
> practical applications will be my J playing field for the foreseeable...
> >
> >
> >
> >
> > On Thu, 2010-12-09 at 22:57 -0500, 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).
> > >
> > > 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
> >
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
>
> ------------------------------
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> End of Programming Digest, Vol 63, Issue 8
> ******************************************
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to