I made a more generic version that is an adverb which takes a conversion
function to be applied to each line. (was ". in our example)
i2t=: 1 : '; (<@:(<@:u@:{. [`( , $:)@.(*@#@]) }.);.1~ [: (=<./) ('' ''
i.&1@:~: ])"1) y'
a -: ". i2t treetest
1
dltb i2t treetest NB. will look the sam
Fantastic! Thank you.
On another note, $: can be frustrating to attempt to use because syntax/domain
errors often/usually/always crash J (8.01)
- Original Message -
From: Marshall Lochbaum
To: 'Pascal Jasmin' via Programming
Cc:
Sent: Wednesday, June 18, 2014 7:14:24 PM
Subject: Re:
You can use recursion ($:) to generate the required tree.
a -: {.L:1 $:^:(0@:tree2 ". leaf <^:(2 %~ 0 i.~' '=]) "1 treetest
Note that {.L:1 is required as otherwise the leaves would be lists of
length 1. I'm not sure how to prevent that from happening within the
verb that uses $: .
Here's anoth
Here's a fairly direct translation to tacit:
hd=: 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8
l1=: ] +. ~:@:(*-.)
f1edy=: (<:@[ ; ]) (1&{::@[ l1 ])^:(0&{::@[) ~:@]
2 f1edy hd
1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 1
3 f1edy hd
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1
4 f1edy hd
1 1 1 1 1 1 1
all one line,
treetest =: >(((<' ') ('' ,~ ] #~ [ * <:@:#@:])"0 1~ each [: #S:1 {::) , each
<@": S:0) a=: (fac =: 3 : 'q =. q: y if. 1<#q do. (y ; [: fac "0 each y (] ,
%) ([: */ ] {~ # ?~ <.@:-:@:#)) q else. < y end.') 176715
treetest
1767150
189
9
3
3
Marshall said:
>> f1 =. (] +. ~:@:(*-.)) ~:
...
>> f2 =. (2&{.)^:(2<#)(<@)/.(;@:) i.@#
>> which isn't exactly pretty, but at least allows you to change the number of
>> values you want. It's also much slower than f1:
>i admit the idea it couldn`t be modified for arbitrary numbers has been
>bugg
On Wed, Jun 18, 2014 at 9:11 AM, 'Pascal Jasmin' via Programming
wrote:
> ... it is extremely unlikely that you want to use !. with a "random"
> verb, and so a sentence would be tied closely to !., and its likely
> that the sentence was not intended.
Yes.
Imagine a discussion of the behavior of
Though its hard to see usefulness of the feature, it does have the advantage of
shortcutting parsing for a primitive, and it is extremely unlikely that you
want to use !. with a "random" verb, and so a sentence would be tied closely to
!., and its likely that the sentence was not intended.
Stil
I think it's a feature.
--
Raul
On Wed, Jun 18, 2014 at 7:02 AM, bill lam wrote:
> I found !. does not work if the verb on its left is a name instead of
> primitive, eg
>
> {. !.1 '' NB. ok
> head=. {.
> head !.1 '' NB. domain error
>
> Is this a feature or a bug?
>
> Interestingly assigning
I found !. does not work if the verb on its left is a name instead of
primitive, eg
{. !.1 '' NB. ok
head=. {.
head !.1 '' NB. domain error
Is this a feature or a bug?
Interestingly assigning a name to !. itself is ok
{.fit 1 ''
tested on J6 and J7 engine.
---
10 matches
Mail list logo