Hash from two arrays: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: modified code to work with Sidef 2.10)
Line 1,551: Line 1,551:
===Explicit construction and stuffing===
===Explicit construction and stuffing===


<lang txrlisp>(defun hash-from-two (vec1 vec2 . hash-args)
<lang txr>@(do
(defun hash-from-two (vec1 vec2 . hash-args)
(let ((table (hash . hash-args)))
(let ((table (hash . hash-args)))
(mapcar (do sethash table) vec1 vec2)
(mapcar (do sethash table) vec1 vec2)
table))
table))


(prinl (hash-from-two #(a b c) #(1 2 3))))</lang>
(prinl (hash-from-two #(a b c) #(1 2 3)))</lang>


<pre>$ ./txr hash-from-two.txr
<pre>$ ./txr hash-from-two.tl
#H(() (c 3) (b 2) (a 1))</pre>
#H(() (c 3) (b 2) (a 1))</pre>