Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,6 @@
|
|||
iex(1)> keys = [:one, :two, :three]
|
||||
[:one, :two, :three]
|
||||
iex(2)> values = [1, 2, 3]
|
||||
[1, 2, 3]
|
||||
iex(3)> Enum.zip(keys, values) |> Enum.into(Map.new)
|
||||
%{one: 1, three: 3, two: 2}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
my @keys = <a b c d e>;
|
||||
my @vals = ^5;
|
||||
my %hash = @keys Z @vals;
|
||||
my %hash = flat @keys Z @vals;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
my @v = <a b c d e>;
|
||||
my %hash = @v Z @v.keys;
|
||||
my %hash = @v Z=> @v.keys;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ <a b c d e> Z=> ^5 }
|
||||
%( <a b c d e> Z=> ^5 )
|
||||
|
|
|
|||
9
Task/Hash-from-two-arrays/Rust/hash-from-two-arrays.rust
Normal file
9
Task/Hash-from-two-arrays/Rust/hash-from-two-arrays.rust
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
let keys = ["a", "b", "c"];
|
||||
let values = [1, 2, 3];
|
||||
|
||||
let hash = keys.iter().zip(values.iter()).collect::<HashMap<_, _>>();
|
||||
println!("{:?}", hash);
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
@(do
|
||||
(defun hash-from-two (vec1 vec2 . hash-args)
|
||||
(let ((table (hash . hash-args)))
|
||||
(mapcar (do sethash table) vec1 vec2)
|
||||
table))
|
||||
(defun hash-from-two (vec1 vec2 . hash-args)
|
||||
(let ((table (hash . hash-args)))
|
||||
(mapcar (do sethash table) vec1 vec2)
|
||||
table))
|
||||
|
||||
(prinl (hash-from-two #(a b c) #(1 2 3))))
|
||||
(prinl (hash-from-two #(a b c) #(1 2 3)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue