Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Hash-from-two-arrays/Neko/hash-from-two-arrays.neko
Normal file
20
Task/Hash-from-two-arrays/Neko/hash-from-two-arrays.neko
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
<doc><h2>Hash from two arrays, in Neko</h2></doc>
|
||||
**/
|
||||
|
||||
var sprintf = $loader.loadprim("std@sprintf", 2)
|
||||
|
||||
var array_keys = $array("one",2,"three",4,"five")
|
||||
var array_vals = $array("six",7,"eight",9,"zero")
|
||||
var elements = $asize(array_keys)
|
||||
|
||||
var table = $hnew(elements)
|
||||
|
||||
var step = elements
|
||||
while (step -= 1) >= 0 $hadd(table, $hkey(array_keys[step]), array_vals[step])
|
||||
|
||||
/*
|
||||
$hiter accepts a hashtable and a function that accepts two args, key, val
|
||||
*/
|
||||
var show = function(k, v) $print("Hashed key: ", sprintf("%10d", k), " Value: ", v, "\n")
|
||||
$hiter(table, show)
|
||||
Loading…
Add table
Add a link
Reference in a new issue