]> gitweb.factorcode.org Git - factor.git/commitdiff
hashtables: add a 2hashtable word that is like associate but for two key/value pairs.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 3 Mar 2016 01:16:05 +0000 (17:16 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 3 Mar 2016 01:17:58 +0000 (17:17 -0800)
core/hashtables/hashtables.factor

index 0f6ad5919cd749b9a648a84910b2d23162e63dc8..2c76350194bd94134798db008492bd05096d49f9 100644 (file)
@@ -150,6 +150,9 @@ M: hashtable set-at
     [ 2dup hash@ set-nth-pair ] keep
     hashtable boa ; inline
 
+: 2hashtable ( value0 key0 value1 key1 -- hash )
+    H{ } clone [ set-at ] keep [ set-at ] keep ; inline
+
 <PRIVATE
 
 : collect-pairs ( hash quot: ( key value -- elt ) -- seq )