[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] A scheme library for J programming is not re-inventing t
From: |
Terrence Brannon |
Subject: |
[Chicken-users] A scheme library for J programming is not re-inventing the wheel is it? |
Date: |
Mon, 10 Sep 2007 20:33:11 -0400 |
I've been a fan of J for a long time, and have an implementation of
monadic array processing in J fashion finished. has this sort of thing
been done before? i'm planning on extending it to other J processing
idioms as well.
If you want to play with the source, d/l and install instructions are at
http://redick.metaperl.com
# Apologies in advance to Kon for use of the word "shape" :)
.....................................................................
#;2> (define n (quikary 2 3 4))
#;3> n
#,(array vector ((0 . 1) (0 . 2) (0 . 3)) (((0 1 2 3) (4 5 6 7) (8 9
10 11)) ((12 13 14 15) (16 17 18 19) (20 21 22 23))))
.....................................................................
.Now perform Tally on it with the default infinite rank
.....................................................................
#;4> (Tally n)
2
.....................................................................
As expected, `Tally` tells us that the entire array has 2 items. Let's
use the rank conjunction to produce a version of `Tally` that has
default rank of 2 instead:
.....................................................................
#;5> (define New-Tally-2 (Rank Tally 2))
#;6> (New-Tally-2 n)
#(3 3)
.....................................................................
We told tally that we wanted to process this data as 2-cells stuffed in
a frame of shape 2. And so we got back a result for each frame
position and since there are 3 items in each `3x4` 2-cell, the answer
is 3.
Now let's process our data as a series of 1-cells:
.....................................................................
#;7> (define New-Tally-1 (Rank Tally 1))
#;9> (New-Tally-1 n)
#,(array vector ((0 . 1) (0 . 2)) ((4 4 4) (4 4 4)))
.....................................................................
And finally, let's process the array with rank-0:
.....................................................................
#;10> (define New-Tally-0 (Rank Tally 0))
#;11> (New-Tally-0 n)
#,(array vector ((0 . 1) (0 . 2) (0 . 3)) (((1 1 1 1) (1 1 1 1) (1 1 1
1)) ((1 1 1 1) (1 1 1 1) (1 1 1 1))))
......................................................................
- [Chicken-users] A scheme library for J programming is not re-inventing the wheel is it?,
Terrence Brannon <=