[Jprogramming] depth vector APL translation
ethiejiesa via Programming
programming at jsoftware.com
Wed May 26 01:19:58 UTC 2021
While we're on this thread, I might as well share the couple pieces I have
laying around:
NB. Output a random depth vector of length y
rv=: <:@(1&= # +/\)@(|.~ >:@(i: <./)@(+/\))@(A.~ ?@!@x:@#)@($&1 , $&_1@<:)
NB. Pretty print a tree representation, given a depth vector (inspired by xash)
TM=: 3 4 $ 0 1 0 1 3 1 3 1 2 2 2 2
pp=: |:@(,/)@({&' |o+-'@(,:~ 4 * 2&=)@({::&TM@,/\.)@(0 ,~ (=>:) + 2*=)"_ 0 ~.)
The above are verbosely documented in the attached script.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tree.ijs.txt
URL: <http://jsoftware.com/pipermail/programming/attachments/20210526/f855c003/attachment.txt>
More information about the Programming
mailing list