From e40e51d8a8b301fc08c337d04768a4f208cd23f8 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Thu, 19 Dec 2024 21:34:06 -0500 Subject: [PATCH] Update hashTable methods Now specify that they take BasicList arguments and move from typicalvalues.m2. Also document missing function variant. --- M2/Macaulay2/d/hashtables.dd | 2 ++ M2/Macaulay2/m2/typicalvalues.m2 | 2 -- M2/Macaulay2/packages/Macaulay2Doc/types.m2 | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/M2/Macaulay2/d/hashtables.dd b/M2/Macaulay2/d/hashtables.dd index 0628e53e099..316b9df4b91 100644 --- a/M2/Macaulay2/d/hashtables.dd +++ b/M2/Macaulay2/d/hashtables.dd @@ -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")) diff --git a/M2/Macaulay2/m2/typicalvalues.m2 b/M2/Macaulay2/m2/typicalvalues.m2 index c353e341f3f..7b393266b45 100644 --- a/M2/Macaulay2/m2/typicalvalues.m2 +++ b/M2/Macaulay2/m2/typicalvalues.m2 @@ -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 diff --git a/M2/Macaulay2/packages/Macaulay2Doc/types.m2 b/M2/Macaulay2/packages/Macaulay2Doc/types.m2 index 002f7847883..da6c6c40ce9 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/types.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/types.m2 @@ -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{},