Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 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