[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Tree Traversal in gnu-apl

From: Rowan Cannaday
Subject: Re: [Bug-apl] Tree Traversal in gnu-apl
Date: Wed, 9 Oct 2019 12:40:19 -0400

Given a recursive factorial definition:
fact←{{⍵ × fact ⍵-1}⍣(⍵>2)⊢1⌈⍵}

[written by Kacper Gutowski in the 'Recursive Lambda' thread]

I am attempting to write a basic accumulator. This should take an empty vector as the left value argument, and a rank 1 array as the right value argument.
Every iteration it should drop a value from the right value, and append it to the left, until the right value is an empty vector.

I thought I'd be able to do something like the following:
acc←{⍺,{acc 1↑⍵}⍣(0=⍴⍵)⊢⍵}
⍬ acc 1 2 3

But modifying this to say, add a 1 to every number, still returns the input vector ⍵.


On Fri, Sep 27, 2019 at 3:44 PM Rowan Cannaday <address@hidden> wrote:
Hello y'all.

I have been attempting to learn function composition & higher-order functions in gnu-apl, and how to use it to perform tree traversal.


Unfortunately a lot of the syntax used is dyalog & dfn specific, so working out some of the examples is a bit tricky for myself.
(the main inconsistencies are '∇' as a recursive function definition, ⍺⍺ & ⍵⍵ to refer to left and right operands, '@' as the 'at' operator, '⍣' operator differences, as well as possibly others).

Has anybody done 'idiomatic' tree traversal in gnu-apl? Does anybody use primitive composition functions in their code?

Trying to figure out what works and feels natural in the language. Any examples or guidance would be appreciated.


Higher order fns in gnu-apl:
∇Z ← (L twice) B
    Z ← L L B

∇Z ← plusthree B
    Z ← B + 3

∇Z ← g B
    Z ← plusthree twice B

reply via email to

[Prev in Thread] Current Thread [Next in Thread]