September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,9 +0,0 @@
|
|||
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));
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
(%i32) catch(findneedle("Zag", haystack, 'f));
|
||||
(%o32) 2
|
||||
(%i33) catch(findneedle("Zag", haystack, 'l));
|
||||
(%o33) 7
|
||||
(%i34) catch(findneedle("Washington", haystack));
|
||||
(%o34) notfound
|
||||
(%i35) catch(findneedle("Bush", haystack, 'f));
|
||||
(%o35) 5
|
||||
(%i36) catch(findneedle("Zag", haystack));
|
||||
(%o36) [2, 7]
|
||||
(%i37) catch(findneedle("Zag", haystack, 'l));
|
||||
(%o37) 7
|
||||
Loading…
Add table
Add a link
Reference in a new issue