i all the A langs

This commit is contained in:
Ingy döt Net 2013-04-10 14:16:51 -07:00
parent 86c034bb8b
commit 9246b988c7
245 changed files with 3941 additions and 0 deletions

View file

@ -0,0 +1,24 @@
FORMAT hay stack := $c("Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo")$;
FILE needle exception; STRING ref needle;
associate(needle exception, ref needle);
PROC index = (FORMAT haystack, REF STRING needle)INT:(
INT out;
ref needle := needle;
getf(needle exception,(haystack, out));
out
);
test:(
[]STRING needles = ("Washington","Bush");
FOR i TO UPB needles DO
STRING needle := needles[i];
on value error(needle exception, (REF FILE f)BOOL: value error);
printf(($d" "gl$,index(hay stack, needle), needle));
end on value error;
value error:
printf(($g" "gl$,needle, "is not in haystack"));
end on value error: reset(needle exception)
OD
)

View file

@ -0,0 +1,28 @@
[]STRING hay stack = ("Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo");
PROC index = ([]STRING hay stack, STRING needle)INT:(
INT index;
FOR i FROM LWB hay stack TO UPB hay stack DO
index := i;
IF hay stack[index] = needle THEN
found
FI
OD;
else:
LWB hay stack - 1
EXIT
found:
index
);
test:(
[]STRING needles = ("Washington","Bush");
FOR i TO UPB needles DO
STRING needle := needles[i];
INT result = index(hay stack, needle);
IF result >= LWB hay stack THEN
printf(($d" "gl$, result, needle))
ELSE
printf(($g" "gl$,needle, "is not in haystack"))
FI
OD
)

View file

@ -0,0 +1,9 @@
haystack = Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo
needle = bush, washington
Loop, Parse, needle, `,
{
If InStr(haystack, A_LoopField)
MsgBox, % A_LoopField
Else
MsgBox % A_LoopField . " not in haystack"
}