Skip to content

Commit

Permalink
replace => operator with KEY operator in hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
squell committed Dec 18, 2021
1 parent 6e74c4a commit 0b3fbcb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions 12/hash.a68
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ COMMENT
PROC new dictionary = DICT:
(DICT res; FOR i FROM LWB res TO UPB res DO res[i] := (0, HEAP[1]DICTENTRY) OD; res);

PRIO => = 2;
OP => = (REF DICT map, STRING word)REF DATUM:
PRIO KEY = 2;
OP KEY = (REF DICT map, STRING word)REF DATUM:
BEGIN
INT pos = HASH word MOD (UPB map+1);
REF REF []DICTENTRY list = bins OF map[pos];
Expand Down
6 changes: 3 additions & 3 deletions 12/solve.a68
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ BEGIN
DO
STRING a,b;
read((a,LOC CHAR,b,new line));
connections=>a +:= b;
connections=>b +:= a
connections KEY a +:= b;
connections KEY b +:= a
OD;
done reading:
SKIP
Expand All @@ -49,7 +49,7 @@ PROC walk = (STRING entry, goal)VOID:
PROC go = (STRING cur)VOID:
(
cur path +:= cur;
[]STRING next = map=>cur;
[]STRING next = map KEY cur;
IF cur = goal THEN
total paths +:= 1;
printf(($n(UPB cur path-1)(g",")gl$, cur path))
Expand Down
6 changes: 3 additions & 3 deletions 12/solve2.a68
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ BEGIN
DO
STRING a,b;
read((a,LOC CHAR,b,new line));
connections=>a +:= b;
connections=>b +:= a
connections KEY a +:= b;
connections KEY b +:= a
OD;
done reading:
SKIP
Expand All @@ -50,7 +50,7 @@ PROC walk = (STRING entry, goal)VOID:
PROC go = (STRING cur)VOID:
(
cur path +:= cur;
[]STRING next = map=>cur;
[]STRING next = map KEY cur;
IF cur = goal THEN
total paths +:= 1;
CO printf(($n(UPB cur path-1)(g",")gl$, cur path)) CO
Expand Down
4 changes: 2 additions & 2 deletions 14/solve.a68
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN
DO
STRING key;
readf(($2a " -> " al$, key));
rules=>key[1:2] := key[3]+key[2]
rules KEY key[1:2] := key[3]+key[2]
OD;
done reading:
SKIP
Expand All @@ -21,7 +21,7 @@ BEGIN
[2*UPB s-1]CHAR new;
new[1] := s[1];
FOR i TO UPB s-1 DO
new[2*i:2*i+1] := rules=>s[i:i+1]
new[2*i:2*i+1] := rules KEY s[i:i+1]
OD;
s := new
END;
Expand Down

0 comments on commit 0b3fbcb

Please sign in to comment.