for your example
example=:0 :0
line 1
        line 2
   line 3
        line 4
     line 5
)

I think the result is like lisp:
(1
 (2))
(3
 (4))
(5)

I think the rule is if the line below is indented, you leave the current line's 
parenthesis open.  If the line below is outdented, then you add an extra 
parentheses to close off your parent.  If that line is outdented futher than 
your immediate parent, then you close off that parent too and check one level 
up.
That's what I'm looking for anyway.  Is the problem easier by starting with S 
expressions (above parenthesized form without white space)?  


I'm having a hard time understanding your solution.


blocks=: [: +/\ ' ' ~: {."1
nest2=: <@{.`({. <@,&< (blocks $:/. ])@(}."[EMAIL PROTECTED]))@.({. <&(' 
'&[EMAIL PROTECTED]) {:)
nest2 [;._2 test

In the rhs to agenda, '({. <&(' '&[EMAIL PROTECTED]) {:)' I don't get why 
comparing the head to the tail is relevant.

Its very impressive that you can keep track of what and where the dyads are in 
that sentence, but that got me lost, even if comparing head and tail is 
appropriate.  Studying your code did make me understand an important 
application of dyad &, but its overall too much of a stretch for me to fully 
appreciate.

it doesn't quite match the spec:

sample =: (0{t),< (1{t), (2{t) , <( 3{t) , (< ( (4{t) ,<5{t )) , (<(  6{t), ( < 
(7{t),< ( (8{t), 9 {t))),  10{t [ t =. ,. <"1@:(": ;. _2) test NB. all one line

test =: 0 : 0
html
 head
 body
  p stuff
  p div='adiv'
   more stuff    
  table
   tr
    td 1
    td 2
  p last stuff
)

The only way I can think of implementing is recursive with a global variable 
tracking across calls.









__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to