glad you enjoyed,

the conjunctions also let you cut down on parens
to banish even more of them:
   bea=: 1 : ';/ m' 
   ba=: 1 : '< m' 
   wa=: 1 : ';: m'

'total quantity'ba 4 2 ba} (([: +/&.:> 1 1 to 3 1 { ])  4 1 ba} ]) 'rice beans 
eggs'wa 1 0 to 3 0 } 1 2 3 bea  1 1 to 3 1} 'foods qty'wa 0 0 to 0 1} 5 3 $ < ''


----- Original Message -----
From: Joe Bogner <[email protected]>
To: [email protected]
Cc: 
Sent: Monday, August 18, 2014 9:15:42 PM
Subject: Re: [Jprogramming] dsl for spreadsheet like input selectors

Pascal, thanks for sharing. It reminds me of sc in some ways. I doubt I'd
use it for this purpose but it was fun to play with and it seems like an
easier syntax for ammend

]s=:5 3 $ <''
]s=:(<'foods')(0 0 to 0 0) } s
]s=:(<'qty')(0 1 to 0 1) } s
]s=:(<"0@+&[email protected]) (1 1 to 3 1) } s
]s=:('rice';'beans';'eggs') (1 0 to 3 0) } s
]s=:(< +/ >(1 1 to 3 1) { s) (4 1 to 4 1) } s
]s=:(<'total quantity') (4 2 to 4 2) } s

┌─────┬───┬──────────────┐
│foods│qty│              │
├─────┼───┼──────────────┤
│rice │1  │              │
├─────┼───┼──────────────┤
│beans│2  │              │
├─────┼───┼──────────────┤
│eggs │3  │              │
├─────┼───┼──────────────┤
│     │6  │total quantity│
└─────┴───┴──────────────┘

[1] - http://www.linuxjournal.com/article/10699


On Mon, Aug 18, 2014 at 5:39 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:

> sorry, mistyped to2
>
>   to2
> =: [: <"1 [: ,."0/&>/ [ +&.> [: i.@:>:&.> -~
>
>
> ----- Original Message -----
> From: Brian Schott <[email protected]>
> To: Programming forum <[email protected]>
> Cc:
> Sent: Monday, August 18, 2014 5:32:43 PM
> Subject: Re: [Jprogramming] dsl for spreadsheet like input selectors
>
> I am not getting good results with to2.
> I am playing with the following.
>
>   CP=: {@(,&<)
>    cross =: [: CP &>/< @:i.@>:"0
>    0 1 -.~&(,&cross) 2 3
> ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
> │0 2│0 3│1 0│1 1│1 2│1 3│2 0│2 1│2 2│2 3│
> └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
>
>
>
> On Mon, Aug 18, 2014 at 4:25 PM, 'Pascal Jasmin' via Programming <
> [email protected]> wrote:
>
> > spreadsheets have a range selection syntax like A1:C3&F4~B2  which means
> > the block range from A1 to C3 with the cell F4 added, and the cell B2
> > removed.
> >
> > Ignoring the letter conversions, here are some useful J functions for
> > building a list of selectors (can be used with both { and }).
> Conjunctions
> > are used for their power to be higher precedence functions, and reduction
> > of parentheses.  Perhaps the only really neat feature of this dsl is the
> > use of conjunctions, as the functions themselves are pretty simple.  At
> the
> > same time, the conjunctions might get in the way if using these functions
> > within forks.
> >
> > the 3 core spreadsheet combiners:
> >
> > to2 =: ( [: <"1 [: ,."0/&>/ [: i.@:>: each -~)
> > to =: 2 : 'm ,@:to2 n'
> > and=: ~.@:,&boxopen
> > less =: -.&boxopen
>
>
>
> >
> >
> --
> (B=)
> ----------------------------------------------------------------------
> 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

Reply via email to