Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Search-a-list/Maxima/search-a-list.maxima
Normal file
9
Task/Search-a-list/Maxima/search-a-list.maxima
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
haystack: ["Zig","Zag","Wally","Ronald","Bush","Zig","Zag","Krusty","Charlie","Bush","Bozo"];
|
||||
needle: "Zag";
|
||||
|
||||
findneedle(needle, haystack, [opt]):=block([idx],
|
||||
idx: sublist_indices(haystack, lambda([w], w=needle)),
|
||||
if emptyp(idx) then throw('notfound),
|
||||
if emptyp(opt) then return(idx),
|
||||
opt: first(opt),
|
||||
if opt='f then first(idx) else if opt='l then last(idx) else throw('unknownmode));
|
||||
Loading…
Add table
Add a link
Reference in a new issue