Skip to content

Commit

Permalink
Update hashTable methods
Browse files Browse the repository at this point in the history
Now specify that they take BasicList arguments and move from
typicalvalues.m2.  Also document missing function variant.
  • Loading branch information
d-torrance committed Dec 28, 2024
1 parent 12a88ba commit e40e51d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions M2/Macaulay2/d/hashtables.dd
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,13 @@ export toHashTable(v:Sequence):Expr := (
Expr(sethash(o,false)));
toHashTable(e:Expr):Expr := (
when e
-- # typical value: hashTable, BasicList, HashTable
is w:List do toHashTable(w.v)
is s:Sequence do (
if length(s) == 2 then (
if isFunction(s.0) then (
when s.1
-- # typical value: hashTable, Function, BasicList, HashTable
is w:Sequence do toHashTableWithCollisionHandler(w, s.0)
is w:List do toHashTableWithCollisionHandler(w.v, s.0)
else WrongArg(2, "a list or sequence"))
Expand Down
2 changes: 0 additions & 2 deletions M2/Macaulay2/m2/typicalvalues.m2
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ take(BasicList,ZZ) := take(BasicList,List) := BasicList => take
take(Thing,ZZ) := take(Thing,List) := List => take

isMutable(Thing) := Boolean => isMutable
hashTable List := HashTable => hashTable
hashTable(Function,List) := HashTable => hashTable
remove(MutableList,ZZ) := Nothing => remove
remove(Database,String) := Nothing => remove
remove(HashTable,Thing) := Nothing => remove
Expand Down
5 changes: 4 additions & 1 deletion M2/Macaulay2/packages/Macaulay2Doc/types.m2
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,10 @@ document {
}

document {
Key => {hashTable,(hashTable, List)},
Key => {
hashTable,
(hashTable, BasicList),
(hashTable, Function, BasicList)},
Headline => "make a hash table",
TT "hashTable(h,v)", " -- produce a hash table from a list ", TT "v", " of key-value pairs, with an optional collision handler function ", TT "h", ".",
PARA{},
Expand Down

0 comments on commit e40e51d

Please sign in to comment.