On Fri, Jul 20, 2012 at 4:02 PM, David Ward Lambert
<[email protected]> wrote:
> Question 1) 5!:6 can parenthesize trains, nouns, adverbs, and verbs.
>
> 5!:6@:<'hook'
> ((0;(3 4 2$0);(0$0);0 _1 0 _1)&;:) (7 (+~) +)
Here's a quick implementation to illustrate the types of each
parenthesized expression in the 5!:6 representation of a verb:
dispcomponents=:1 :0
text=: 5!:6 <'u'
levels=: (>. _1 }. {.,])+/\ -/'()'=/text
for_n. \:~~.levels do.
docFrag&> }. ~. a:,(n > _1,levels) <;._1 ' ',text
end.
i.0 0
)
fragType=: 3 :0
". 'test=.',y
nc <'test'
)
fragTypeName=: {&(;:'noun adverb conjunction verb illformed undefined')@fragType
docFrag=: 3 :0
smoutput (;@fragTypeName,': ',]) y
)
Here's an example of how it looks in action:
(((0;(3 4 2$0);(0$0);0 _1 0 _1)&;:) (7 (+~) +)) dispcomponents
noun: (3 4 2$0)
noun: (0$0)
noun: (0;(3 4 2$0);(0$0);0 _1 0 _1)
verb: (+~)
verb: ((0;(3 4 2$0);(0$0);0 _1 0 _1)&;:)
verb: (7 (+~) +)
verb: ((0;(3 4 2$0);(0$0);0 _1 0 _1)&;:) (7 (+~) +)
(I'm not returning a result, here, because I can't think of any use
for a result of this form.)
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm