« first day (987 days earlier)      last day (1668 days later) » 

8:13 AM
0
Q: How to build own Each operator using Rank operator in Dyalog APL

Yuliia Serhiienko I saw answer in this question How to use rank operator instead of each in APL how to build own Each operator using Rank ⍤. Monadic Each f¨x can be represented as {⊂f⊃⍵}⍤0⊢x Dyadic Each x f¨y can be represented as x{⊂(⊃⍺)f(⊃⍵)}⍤0⊢y In terms of this please answer following questions: Why Eac...

 
 
1 hour later…
9:14 AM
0
Q: How do I get current timestamp in seconds?

August KarlstromIn Dyalog APL I can use the function ⎕TS to get the current year, month, day, hour, minute, second etc, but is there a way to get the current timestamp in seconds from e.g. 1970-01-01 (Unix timestamp)?

 
 
6 hours later…
ngn
3:30 PM
@Sherlock9 here's an idea: if we have a list of results candidates of length L-1, we could build the list for L by appending the elements of m to old candidates in all possible ways. this can be optimised by keeping only candidates with distinct sums that are ≤⍵. so, starting with candidate list ,⊂⍬, after steps we'll find a valid result (if it exists) without using the 15+ dimensional ∘.+.
⎕←3{m←+\+\1,⍵⍴⍺-2 ⋄ w←⍵ ⋄ ⊃a/⍨⍵=+/↑a←{a/⍨(w∘≥∧⍳⍨=⍳∘≢)+/↑a←,m∘.,⍵}⍣⍺,⊂⍬}17
 
@ngn
1 1 15
 
 
2 hours later…
5:48 PM
has anybody done tree traversal in gnu apl?
my goal is essentially to do the following in gnu-apl, using lambdas as much as possible:
https://youtu.be/DsZdfnlh_d0

im starting out building a basic accumulator (that adds 1 to each number):
foo ← {{(1+1↑⍵),(foo 1↓⍵)}⍣(~0=⍴⍵)⍵}

however I cant get it to play nice with a left argument empty vector
heres the help page btw:

dyadic operator: Z ← A (F ⍣ G) B (Power Operator)
repeat: B ← A F B until (A F B) G B is true (function G)
 
ngn
6:24 PM
@cannadayr shouldn't there be a between (~0=⍴⍵) and to prevent stranding?
other apls require it. i can't test with gnuapl as i'm having difficulties installing it on 64 bit debian.
 
thx. heres updated (with attempt at left arg)
foo ← {⍬{⍺,(1+1↑⍵),(foo 1↓⍵)}⍣(~0=⍴⍵)⊢⍵}
foo 1 2 3
2 3 4

although trying to replace the zilde with alpha yields following:
foo ← {⍺{⍺,(1+1↑⍵),(foo 1↓⍵)}⍣(~0=⍴⍵)⊢⍵}
⍬ foo 1 2 3
VALUE ERROR
foo[1] λ←⍺ λ1⍣(∼0=⍴⍵)⊢⍵
^
 
ngn
@cannadayr i don't know what you're trying to achieve with ⍺ and ⍬ but it seems the reason for the error is that the function application foo 1↓⍵ doesn't have anything on the left of foo
 
ahh thats helpful.
i was using ⍬ as the initial accumulator
and ⍺ would be the accumulated values in each iteration
 
ngn
6:41 PM
maybe i should re-watch the video. last i watched it was a long time ago...
 
yea im not stuck on that method
here is a more indepth explanation
basically just working out a relatively modern 'idiomatic' method of tree traversal (and more generally recursive higher order functions) w/ gnu apl
a lot of the examples use dyalog operators that don't have a straightforward analog
(at least for me - im a n00b)
 
ngn
@cannadayr in dyalog ad hoc recursion is relatively simple with ("recur" - this is an alias for the function that's currently being executed) and guards ({condition:then ⋄ else}). i'm not familiar enough with gnu apl to make a comparison.
 
yup basically where im at. darn me and my FOSS adherence...
thx for the help tho
btw +1 for your js apl interpreter. ive only messed around w/ it briefly but its nice.
might try it w/ this ifelse implementation
https://stackoverflow.com/questions/15752895/conditional-function-in-apl
 
ngn
6:57 PM
@cannadayr thanks! i haven't been doing any work on it for a while, as i became more interested in k, but luckily newer and more complete apl-like language implementations appeared, like dzaima/apl for instance
 
ahh interesting.
k seems very cool, but i wish it used the apl character set.
i know theres emacs pretty mode
 
ngn
@cannadayr the newest k, also known as "shakti" (not yet released), will probably use some non-ascii characters
also k is very different from apl. it's more distant from apl than j is. for instance it only supports scalars and vectors, no matrices (except as vectors of vectors). so, many of the primitive operations in apl don't translate literally to k.
 
yea, i personally rly like the apl design. I found that after a few months I was starting to think in the character set even in other programming languages.
whenever i look at J/K its difficult for me to parse the overloaded terms (but that might just be one of familiarity)
 
ngn
@cannadayr i find j difficult to parse because of the use of digraphs (i.e. . and : as "inflections")
k doesn't have digraphs (except for the 3 uses of : in adverbs) but indeed it has heavy overloading because the printable ascii range is so small
 
ngn
7:25 PM
j is confusing because of the unbalanced [ ] { } too
 
8:14 PM
closer btw
foo ← {⍺,{((1+1↑⍵) foo 1↓⍵)}⍣(~0=⍴⍵)⊢⍵}
⍬ foo 1 2 3
2 3 4
5 4 3 foo 1 2 3
5 4 3 2 3 4
 

« first day (987 days earlier)      last day (1668 days later) »