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,42 +1,17 @@
integer
void
search(list l, text s)
{
integer i;
i = 0;
while (i < l_length(l)) {
if (!compare(l_q_text(l, i), s)) {
while (i < ~l) {
if (!compare(l[i], s)) {
break;
}
i += 1;
}
if (i == l_length(l)) {
i = -1;
}
return i;
}
void
search_for(list l, ...)
{
integer i;
i = 1;
while (i < count()) {
integer index;
index = search(l, $i);
o_text($i);
if (index == -1) {
o_text(" is not in the haystack\n");
} else {
o_plan(" is at ", index, "\n");
}
i += 1;
}
o_(s, " is ", i == ~l ? "not in the haystack" : cat("at ", itoa(i)), "\n");
}
integer
@ -46,7 +21,7 @@ main(void)
l = l_effect("Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty",
"Charlie", "Bush", "Boz", "Zag");
search_for(l, "Bush", "Washington", "Zag");
__ucall(search, 1, 1, l, "Bush", "Washington", "Zag");
return 0;
}