This is the first announcement for Redick. Originally I wanted to
learn Java as well as learn J, so I started on a Java implementation
of J. Which naturally would be called JJ. And the most famous JJ? Why
JJ Redick. Hence the name Redick.

However, i soon realized that Scheme was a very nice fit for J and it
has a very nice array class as an add-on. So I started on one version
in Scheme and got a good number of monads and dyads written when I
started to run in rank issues.

Deep study of Henry Rich's J for C Programmers forced me to go back to
scratch once again. Now, I have monadic # implemented and implemented
properly:

(define (monad-apply verb noun)
  (let* ([v-rank (verb 'get 'rank)]
         [n-rank (RankOf noun)]
         [r (calc-r v-rank n-rank)]
         [f (calc-f (ShapeOf noun) r)]
         [n-cells (array-split* noun (frame-length f))]
         [framed-cells (result-array f n-cells)]
         [v-action (verb 'get 'action)]
         )
    (if (null? (frame-shape f))   ;; is the frame empty?
        ;; if so, then apply the verb to the input array as a whole
        (v-action framed-cells)
        ;; otherwise go into each frame and apply verb to data there
        (array-index-map!
         framed-cells
         (lambda indices
           (let ([elem (apply array-ref framed-cells indices)])
             (v-action elem)))))))

And you can download and play with the installation:

   http://redick.metaperl.com

But in case that is too much work, I append the userguide for your
visual consumption. More news later. Thanks for listening!

Redick User Guide
=================

.Load the file `verbs.scm` into the Chicken Scheme interpreter:
......................................................................

      /    /      /
 ___ (___    ___ (     ___  ___
|    |   )| |    |___)|___)|   )
|__  |  / | |__  | \  |__  |  /

Version 2.6 - windows-cygwin-x86 - [ dload ptables applyhook ]
(c)2000-2007 Felix L. Winkelmann
#;1> ; loading /home/W049945/prg/redick/scheme/verbs.scm ...
; loading /usr/local/lib/chicken/1/syntax-case.dll ...
; loading /usr/local/lib/chicken/1/syntax-case-chicken-macros.scm ...
; loading /usr/local/lib/chicken/1/pos.scm ...
; loading /usr/local/lib/chicken/1/pos-support.dll ...
; loading alist.scm ...
; loading monads.scm ...
; loading /usr/local/lib/chicken/1/array-lib.dll ...
; loading /usr/local/lib/chicken/1/array-lib-sem.dll ...
; loading /usr/local/lib/chicken/1/misc-extn-list-support.dll ...
; loading /usr/local/lib/chicken/1/misc-extn-condition-support.dll ...
; loading /usr/local/lib/chicken/1/array-lib-hof.dll ...
; loading /usr/local/lib/chicken/1/array-lib-sub.dll ...
; loading /usr/local/lib/chicken/1/box.scm ...
; loading /usr/local/lib/chicken/1/box-support.dll ...
; loading monads/monad-apply.scm ...
; loading monads/Rank.scm ...
; loading monads/RankOf.scm ...
; loading monads/Shape.scm ...
; loading monads/Integers.scm ...
; loading monads/ShapeOf.scm ...
; loading monads/Tally.scm ...
; loading util.scm ...
.....................................................................

.Now build a rank 3 array of shape `2 3 4`
.....................................................................
#;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))))
......................................................................



-- 

J IRC Channel irc://irc.freenode.org/jsoftware
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to