spl/pure.spl
2024-09-08 14:37:32 +02:00

50 lines
791 B
Text

"#stream.spl" import
"uses less native functions where possible";
func pop { | with _ ; }
func dup { x x | with x ;
x x
}
func swap { b a | with a b ;
b a
}
func not { !x | with x ;
1
x if { pop 0 }
}
func and { a&&b | with a b ;
0
a if { b if { pop 1 } }
}
func or { a||b | with a b ;
0
a if { pop 1 }
b if { pop 1 }
}
func alit-end { array | with type ;
def array 0 anew =array
while { dup type eq not } {
awrap array aadd =array
}
pop array
}
func read-file { str | with path ;
def stream path 0 StreamTypes:file:create =stream
1024 stream:read-to-end:to-str
}
func acopy { array | with from to idxsrc idxdst len ;
len:foreach<{ | with i ;
i idxsrc + from:get i idxdst + to:set;
}>
to
}