i all the A langs
This commit is contained in:
parent
86c034bb8b
commit
9246b988c7
245 changed files with 3941 additions and 0 deletions
24
Task/Search-a-list/ALGOL-68/search-a-list-1.alg
Normal file
24
Task/Search-a-list/ALGOL-68/search-a-list-1.alg
Normal 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
|
||||
)
|
||||
28
Task/Search-a-list/ALGOL-68/search-a-list-2.alg
Normal file
28
Task/Search-a-list/ALGOL-68/search-a-list-2.alg
Normal 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
|
||||
)
|
||||
9
Task/Search-a-list/AutoHotkey/search-a-list.ahk
Normal file
9
Task/Search-a-list/AutoHotkey/search-a-list.ahk
Normal 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"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue