What about the verb "paren" in trace.ijs? Is that what you are looking for?

But a warning - the following expression is turned into a hook by paren.

   +((+/)%#)3 4 6
4.33333
   require 'trace'
   paren '+((+/)%#)3 4 6'
((+ ((+ /) % #)) 3 4 6)
((+ ((+ /) % #)) 3 4 6)
7.33333 8.33333 10.3333

On Nov 19, 2007 9:58 AM, Raul Miller <[EMAIL PROTECTED]> wrote:

> On Nov 19, 2007 10:59 AM, Dan Bron <[EMAIL PROTECTED]> wrote:
> > Provide a monad that provides every possible parenthesization of the
> words of its argument.
> > In addition to the standard brevity/elegance/speed metrics, bonus points
> will be awarded for
> > elision of superfluous parens, ordering results by number of parens, and
> tacit solutions.
>
> What are "superfluous" parens, in this context?
>
> For example, should we be assuming some particular kind of word?
>
> For example, does this qualify?
>
> paren1=: <@('(' , ')',~ ;:inv) [EMAIL PROTECTED](1 = [EMAIL PROTECTED])
> parens=: (2 +/\"[EMAIL PROTECTED]:@[EMAIL PROTECTED] #) paren1/.^:(1 < [EMAIL 
> PROTECTED]@[)"1 ]
> parenthesis=: [: ;:inv"1 ([: ~.@; <@[EMAIL PROTECTED]&a:"1)^:_@,:@;:
>
>   parenthesis 'a b c d'
> a b c d
> (a b c) d
> (a b) (c d)
> (a b) c d
> a (b c d)
> a (b c) d
> a b (c d)
> ((a b) c) d
> (a (b c)) d
> a ((b c) d)
> a (b (c d))
>
> I probably should have used boxes rather than a flat list, when grouping
> my candidate sentences  (this would have let me get rid of the -.&a:) but
> I
> am not sure if this is a big enough issue to worry about, and thought I
> should get clarification as well.
>
> Thanks,
>
> --
> Raul
>  ----------------------------------------------------------------------
> 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