Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
Remove duplicate elements, in Neko
|
||||
*/
|
||||
|
||||
var original = $array(1, 2, 1, 4, 5, 2, 15, 1, 3, 4)
|
||||
|
||||
/* Create a table with only unique elements from the array */
|
||||
var dedup = function(a) {
|
||||
var size = $asize(a)
|
||||
var hash = $hnew(size)
|
||||
while size > 0 {
|
||||
var v = a[size - 1]
|
||||
var k = $hkey(v)
|
||||
$hset(hash, k, v, null)
|
||||
size -= 1
|
||||
}
|
||||
return hash
|
||||
}
|
||||
|
||||
/* Show the original list and the unique values */
|
||||
$print(original, "\n")
|
||||
var show = function(k, v) $print(v, " ")
|
||||
$hiter(dedup(original), show)
|
||||
$print("\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue