Henry, I have hit a snag in how @ is working in your program. Why are f
and g different?
(>:@?)~>:i.# 'abcde'
1 0 0 0 0
2 1 0 0 0
1 2 3 0 0
3 2 1 4 0
2 5 3 4 1
([:>:?)~>:i.# 'abcde'
1 1 1 1 1
2 1 1 1 1
1 2 3 1 1
1 3 4 2 1
2 5 1 3 4
f=: 13 :'(>:@?)~>:i.# y'
f 'abcde'
1 0 0 0 0
2 1 0 0 0
1 2 3 0 0
2 3 1 4 0
3 5 2 4 1
g=: 13 :'([:>:?)~>:i.# y'
g 'abcde'
1 1 1 1 1
1 2 1 1 1
3 2 1 1 1
1 3 4 2 1
2 3 5 4 1
5!:4 <'f'
-- [:
│ -- >:
+- ~ --- @ -+- ?
--+
│ -- [:
│ +- >:
L-----+ -- [:
L-----+- i.
L- #
5!:4 <'g'
-- [:
│ -- [:
+- ~ ------+- >:
--+ L- ?
│ -- [:
│ +- >:
L-----+ -- [:
L----+- i.
L- #
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Henry Rich
Sent: Monday, February 27, 2012 10:24 PM
To: Programming forum
Subject: Re: [Jprogramming] Challenge 6 Many Many Cherry Trees
@ has its uses.
tree =. (] ; ;/@,.)&' ' ;@({~ |.)"1 >:@?~@>:@i.@#
tree 'abcde'
a
b a
b a c
b c a d
d b a e c
Henry Rich
On 2/27/2012 9:31 PM, Kip Murray wrote:
> Here is how I would now do it, borrowing sh and the idea of using |.
> from you, Linda.
>
> sh =: ] {~ # ? #
>
> gwk =: ([: |. [: - [: i. #) |."0 1 [: ([ , ' ' , ])/"1 [: sh\ sh
>
> gwk 'abcde'
> b
> d b
> e d b
> e a b d
> b e d c a
>
> Kip
>
> On 2/27/2012 4:35 AM, Linda Alvord wrote:
>> Here is my latest version which has simple tacit definitions. I was
>> impressed with all the different strategies that were submitted and it
>> should provide you with many options to consider and hopefully allow you
to
>> understand J better. I know I learned a lot and I still have many more
>> versions to study.
>>
>> f=: 13 :'((#y)?#y){y'
>> f
>> ] {~ # ? #
>> f 'abcde'
>> deacb
>>
>> g=: 13 :'|. f \. f y'
>> g
>> [: |. [: f\. f
>> g 'abcde'
>> c
>> ac
>> dca
>> eadc
>> eacdb
>>
>> h=: 13 :'|.,"2 |:'' '',:|:|. g y'
>> h
>> [: |. [: ,"2 [: |: ' ' ,: [: |: [: |. g
>> h 'abcde'
>> a
>> e a
>> e a d
>> d b a e
>> a c e d b
>>
>> gw=: 13 :'(,.(1+#y)+i.#y)|."1 h y'
>> gw
>> ([: ,. (1 + #) + [: i. #) |."1 h
>> gw 'cherrytrees'
>> e
>> c e
>> c e r
>> e c h r
>> r y h c e
>> y h t r c e
>> r t r c e y h
>> y c r h t s e r
>> r h e y t r c e s
>> c r t e h s r r y e
>> t s e e y r r h e r c
>>
>> All the tacit expressions are quite simple looking. If I misses some of
your
>> good ideas please let me know. Maybe I can get rid of some of the
>> parentheses in the final verb. I anticipate having some questions about
some
>> of the strategies you've used when I look at them more carefully.
>>
>> Linda
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Linda Alvord
>> Sent: Sunday, February 26, 2012 3:33 PM
>> To: 'Programming forum'
>> Subject: Re: [Jprogramming] Challenge 6 Many Many Cherry Trees
>>
>> I noticed that all the first group begin with c but I didn't notice
that
>> all the last group end with d
>>
>> I don't often find my own problems.
>>
>> Linda
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Linda Alvord
>> Sent: Sunday, February 26, 2012 6:10 AM
>> To: 'Programming forum'
>> Subject: Re: [Jprogramming] Challenge 6 Many Many Cherry Trees
>>
>> Here's more I don't understand.
>>
>> p=: 13 :'((#y)?#y){y'
>> p\p 'abcde'
>> e
>> eb
>> bea
>> bdea
>> baedc
>>
>> Why is this a domain error?
>>
>> (((#y)?#y){y)\((#y)?#y){y=:'abcde'
>> |domain error
>> | (((#y)?#y){y)\((#y)?#y){y=:'abcde'
>>
>> Why is each row not scrambled in the first example but they are in the
>> second?
>>
>> ]\ 'cbaed'
>> c
>> cb
>> cba
>> cbae
>> cbaed
>>
>> ]\. 'cbaed'
>> cbaed
>> baed
>> aed
>> ed
>> d
>>
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Raul Miller
>> Sent: Friday, February 24, 2012 11:57 AM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Challenge 6 Many Many Cherry Trees
>>
>> On Fri, Feb 24, 2012 at 11:39 AM, Kip Murray<[email protected]> wrote:
>>> Raul has explained "0 _ . In effect I was re-inventing<\. (box suffix)
.
>>
>> Or, more specifically:
>> ]\. 'cbaed'
>>
> ----------------------------------------------------------------------
> 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