September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -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));

View file

@ -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