mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-25 16:18:48 +00:00
Better infixes
This commit is contained in:
parent
92f60665df
commit
25ec856fba
11 changed files with 56 additions and 34 deletions
|
|
@ -1,6 +1,6 @@
|
|||
local n;
|
||||
|
||||
infix "===" at "==" (v1, v2) {
|
||||
infix === at == (v1, v2) {
|
||||
local s1, s2, i;
|
||||
|
||||
s1 := v1.string;
|
||||
|
|
@ -17,14 +17,14 @@ infix "===" at "==" (v1, v2) {
|
|||
fi
|
||||
}
|
||||
|
||||
infix "?" before "+" (v, l) {
|
||||
infix ? before + (v, l) {
|
||||
case l of
|
||||
{} -> return 0
|
||||
| h : tl -> if h === v then return 1 else return (v ? tl) fi
|
||||
esac
|
||||
}
|
||||
|
||||
infix "+++" at "+" (l1, l2) {
|
||||
infix +++ at + (l1, l2) {
|
||||
case l1 of
|
||||
{} -> return l2
|
||||
| h : tl -> return (h : tl +++ l2)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fun f (l) {
|
||||
infix "===" at "==" (a, b) {
|
||||
infix === at == (a, b) {
|
||||
return a == b
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
infix "++" at "+" (a, b) {return a+b}
|
||||
infix ++ at + (a, b) {return a+b}
|
||||
|
||||
local x = read ();
|
||||
|
||||
write (infix "++" (2, 3))
|
||||
write (infix ++ (2, 3))
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
infixr "**" before "*" (f, g) {
|
||||
infixr ** before * (f, g) {
|
||||
return fun (x) {return f (g (x))}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local n;
|
||||
|
||||
infix "===" at "==" (v1, v2) {
|
||||
infix === at == (v1, v2) {
|
||||
local s1, s2, i;
|
||||
|
||||
s1 := v1.string;
|
||||
|
|
@ -17,14 +17,14 @@ infix "===" at "==" (v1, v2) {
|
|||
fi
|
||||
}
|
||||
|
||||
infix "?" before "+" (v, l) {
|
||||
infix ? before + (v, l) {
|
||||
case l of
|
||||
{} -> 0
|
||||
| h : tl -> if h === v then 1 else (v ? tl) fi
|
||||
esac
|
||||
}
|
||||
|
||||
infix "+++" at "+" (l1, l2) {
|
||||
infix +++ at + (l1, l2) {
|
||||
case l1 of
|
||||
{} -> l2
|
||||
| h : tl -> (h : tl +++ l2)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fun f (l) {
|
||||
infix "===" at "==" (a, b) {
|
||||
infix === at == (a, b) {
|
||||
a == b
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
infix "++" at "+" (a, b) { a+b}
|
||||
infix ++ at + (a, b) { a+b}
|
||||
|
||||
local x = read ();
|
||||
|
||||
write (infix "++" (2, 3))
|
||||
write (infix ++ (2, 3))
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
infixr "**" before "*" (f, g) {
|
||||
infixr ** before * (f, g) {
|
||||
fun (x) { f (g (x))}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue