melsman / apltail Goto Github PK
View Code? Open in Web Editor NEWAPL Compiler targeting a typed array intermediate language
License: MIT License
APL Compiler targeting a typed array intermediate language
License: MIT License
At the moment, apltail
is a single program that changes behaviour in response to various command line options. I find these hard to remember and use, so I suggest the creation of simpler wrapper programs that encapsulate common operations. For example, I use this apl2tail
script:
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 <tail program>"
exit 1
fi
if ! [ "$TAIL_ROOT" ]; then
echo '$TAIL_ROOT not set - things are unlikely to work' >&2
fi
apl_source=$1
tail_source=${apl_source%.*}.tail
TAIL_PRELUDE=${TAIL_ROOT}/lib/prelude.apl
aplt -p_types -p_tail -c -o "$tail_source" $TAIL_PRELUDE "$apl_source"
life←{ ⍝ John Conway's "Game of Life".
↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ ⍝ Expression for next generation.
}
For the pricer we need conditionals of the form:
mins[1] ≥ 1: return ← 1150.0 × md_disc[1]
See https://github.com/dybber/aplbench/blob/master/finpar-generic-pricer/dyalog/pricer.apl#L174
We might want to simplify the above example code before working more on this
https://twitter.com/dyalogapl/status/755706056005877760
{+/,⍵×⍵=+/¨⍳⍴⍵}?5 5⍴10
It's a modern version of this piece of ancestor worship: http://keiapl.org/anec/#Dijkstra
Right now, the TAIL compiler will give a type error if the last expression is not a scalar of type double. This makes it awkward to write some programs - sure, you can use the print statement, but you still need a dummy 0
or whatever at the end. As an example, look at the mandelbrot.apl test program.
⎕←' #'[9>|⊃{⍺+⍵*2}/9⍴⊂¯3×.7j.5-⍉a∘.+0j1×a←(⍳n+1)÷n←98]
It needs complex numbers. Not sure what else.
Running aplt
on the following APL program
+/ 1 ⌽ ⍳ 10
gives the TAIL program
i2d(reduce{[int],[0]}(addi,0,transp{[int],[1]}(vrotateV(1,transp{[int],[1]}(iotaV(10))))))
I would expect
i2d(reduce{[int],[0]}(addi,0,transp{[int],[1]}(vrotateV{[int],[10]}(1,transp{[int],[1]}(iotaV(10))))))
What prevents apltail from working with MosML?
Running ./aplt tests/sierpinski0.apl
results in the program being evaluated and giving the correct result but then instead of terminating it just uses 100% CPU. Same thing happens with the -c
flag.
We are not far from being able to execute the following one-liner - see http://aplwiki.com/FinnAplIdiomLibrary#Miscellaneous:
⍎⊖⍕⊃⊂|⌊-*+○⌈×÷!⌽⍉⌹~⍴⍋⍒,⍟?⍳0
We will not be able to support execute ⍎
, box ⊂
. So we should, with an implementation of ⌹
be able to compile the following expression:
⊖⍕⊃|⌊-*+○⌈×÷!⌽⍉⌹~⍴⍋⍒,⍟?⍳0
Here is how it looks with http://www.tryapl.org:
Comments:
⍵e need this to be able to switch between sequential or parallel versions of the operators.
It probably has to be rather conservative, and only use the parallel version when the function is one of: max,min,+,*, bitwise xor, bitwise and, bitwise or.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.