Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,15 @@
def nameOf(arg :int) {
if (arg == 43) {
return "Bob"
} else {
throw("Who?")
}
}
def catching(arg) {
try {
return ["ok", nameOf(arg)]
} catch exceptionObj {
return ["notok", exceptionObj]
}
}

View file

@ -0,0 +1,8 @@
? catching(42)
# value: ["not ok", problem: Who?]
? catching(43)
# value: ["ok", "Bob"]
? catching(45.7)
# value: ["not ok", problem: the float64 45.7 doesn't coerce to an int]

View file

@ -0,0 +1,15 @@
def nameOf(arg :int, ejector) {
if (arg == 43) {
return "Bob"
} else {
ejector("Who?")
}
}
def catching(arg) {
escape unnamed {
return ["ok", nameOf(arg, unnamed)]
} catch exceptionObj {
return ["notok", exceptionObj]
}
}

View file

@ -0,0 +1,8 @@
? catching(42)
# value: ["not ok", problem: Who?]
? catching(43)
# value: ["ok", "Bob"]
? catching(45.7)
# problem: the float64 45.7 doesn't coerce to an int

View file

@ -0,0 +1,11 @@
var nameTable := null
def nameOf(arg :int, ejector) {
if (nameTable == null) {
nameTable := <import:nameTableParser>.parseFile(<file:nameTable.txt>)
}
if (nameTable.maps(arg)) {
return nameTable[arg]
} else {
ejector(makeNotFoundException("Who?"))
}
}