add startswith

This commit is contained in:
Daniella / Tove 2022-05-04 19:48:09 +02:00
parent bec43212c1
commit 9e255b8e31
3 changed files with 26 additions and 2 deletions

View file

@ -446,8 +446,7 @@ public class ISBPL {
break;
case "getos":
func = (Stack<ISBPLObject> stack) -> {
// TODO: This is not done yet, and it's horrible so far.
stack.push(toISBPLString("linux"));
stack.push(toISBPLString(System.getProperty("os.name")));
};
break;
case "mktype":

View file

@ -462,3 +462,24 @@ func ] {
}
pop array
}
func astartswith {
def match _array =match
def str _array =str
str alen match alen lt if {
0 2 stop
}
str alen match alen eq if {
str match eq 2 stop
}
def i 0 =i
while { i match alen lt } {
str i aget match i aget eq not if {
0 3 stop
}
i inc
}
1
}

View file

@ -15,6 +15,10 @@ def STREAM.write iota =STREAM.write
def STREAM.create.server iota =STREAM.create.server
func STREAM.stdin {
getos strlowercase "win" astartswith dup if { "conIN$" } not if { "/dev/stdin" }
}
func stream.readline {
def id =id
def byte 0 =byte