2024-09-08 14:27:46 +02:00
|
|
|
"#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 } {
|
2024-09-08 14:37:32 +02:00
|
|
|
awrap array aadd =array
|
2024-09-08 14:27:46 +02:00
|
|
|
}
|
|
|
|
pop array
|
|
|
|
}
|
|
|
|
|
|
|
|
func read-file { str | with path ;
|
|
|
|
def stream path 0 StreamTypes:file:create =stream
|
|
|
|
1024 stream:read-to-end:to-str
|
|
|
|
}
|
|
|
|
|
2024-09-08 14:37:32 +02:00
|
|
|
func acopy { array | with from to idxsrc idxdst len ;
|
2024-09-08 14:27:46 +02:00
|
|
|
len:foreach<{ | with i ;
|
|
|
|
i idxsrc + from:get i idxdst + to:set;
|
|
|
|
}>
|
2024-09-08 14:37:32 +02:00
|
|
|
to
|
2024-09-08 14:27:46 +02:00
|
|
|
}
|