aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.lua
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-06-01 14:16:53 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-06-01 14:16:53 +0200
commit069a0fd86f9bb239476235ed795a3a1d330d203e (patch)
tree92574c2ac9a98a6525ca672dbe482481d5daaeb0 /applause.lua
parentabdcfb5ec271fe585e93f7d79bd109996d5294b2 (diff)
downloadapplause2-069a0fd86f9bb239476235ed795a3a1d330d203e.tar.gz
added a few APLish unicode shortcuts for some of the primitives/Stream methods
* Unicode identifiers allowed in LuaJIT 2 * We add the shortcuts directly to applause.lua but using Unicode escapes. Thus we don't have to maintain a separate file and we can still edit applause.lua using a non-UTF editor like SciTECO * Stream:sub (subtract) renamed to Stream:minus. This was previously overwritten by the SubStream wrapper.
Diffstat (limited to 'applause.lua')
-rw-r--r--applause.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/applause.lua b/applause.lua
index 91c879a..68d233b 100644
--- a/applause.lua
+++ b/applause.lua
@@ -226,6 +226,7 @@ end
function Stream:map(fnc)
return MapStream:new(self, fnc)
end
+Stream["\u{00A8}"] = Stream.map -- APL Double-Dot
-- Register all unary functions from the math package
-- as stream operations/methods (creates a stream that calls
@@ -263,7 +264,7 @@ function Stream:add(n)
return self:map(function(x) return x+n end)
end
-function Stream:sub(n)
+function Stream:minus(n)
return self:map(function(x) return x-n end)
end
@@ -271,10 +272,12 @@ function Stream:mul(n)
return self:map(function(x) return x*n end)
end
Stream.gain = Stream.mul
+Stream["\u{00D7}"] = Stream.mul -- APL Multiply/Signum
function Stream:div(n)
return self:map(function(x) return x/n end)
end
+Stream["\u{00F7}"] = Stream.div -- APL Divide
function Stream:mod(n)
return self:map(function(x) return x%n end)
@@ -283,6 +286,7 @@ end
function Stream:pow(n)
return self:map(function(x) return x^n end)
end
+Stream["\u{22C6}"] = Stream.pow -- APL Exponentiation
function Stream:clip(min, max)
min = min or -1
@@ -371,6 +375,7 @@ end
function Stream.SinOsc(freq)
return Stream.Phasor(freq):mul(2*math.pi):sin()
end
+Stream["\u{25CB}"] = Stream.SinOsc -- APL Circle
-- Pulse between 0 and 1 in half a period (width = 0.5)
function Stream.PulseOsc(freq)
@@ -1706,6 +1711,7 @@ function tostream(v)
end
function iota(...) return IotaStream:new(...) end
+_G["\u{2373}"] = iota -- APL Iota
function line(v1, t, v2)
return iota(t):mul((v2-v1)/t):add(v1)