Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -0,0 +1,22 @@
|
||||
# probe: a function returning Optional, tested and unwrapped
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: ada at 0
|
||||
# expect-stdout: cy at 2
|
||||
# expect-stdout: dee missing
|
||||
# expect-stdout: 0 None
|
||||
def index_of(xs: List[String], x: String) -> Optional[Int]:
|
||||
for i in range(len(xs)):
|
||||
if xs[i] == x:
|
||||
return i
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
var names: List[String] = ["ada", "bo", "cy"]
|
||||
for q in ["ada", "cy", "dee"]:
|
||||
var r = index_of(names, q)
|
||||
if r:
|
||||
print(q, "at", r.value())
|
||||
else:
|
||||
print(q, "missing")
|
||||
print(index_of(names, "ada"), index_of(names, "zed"))
|
||||
Reference in new issue
Block a user