Skip to content

Commit

Permalink
Reimplement Array.uniq to ensure that the order stays the same.
Browse files Browse the repository at this point in the history
  • Loading branch information
treed committed Jul 23, 2009
1 parent 7cacdbb commit 0503fb6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/classes/Array.pir
Expand Up @@ -246,24 +246,26 @@ Return a sorted copy of the list

loop:
if i == len goto done
val = self[i]

key = self[i]

unless block_flag, finish

key = block(key)
$P0 = hash.'value?'(key)
if $P0 goto skip

finish:
hash[key] = val
$I0 = exists hash[key]
if $I0 goto skip

$P0 = self[i]
uarray.'push'($P0)
hash[key] = $P0

skip:
inc i
goto loop

done:
uarray = hash.'values'()
.return (uarray)
.end

Expand Down

0 comments on commit 0503fb6

Please sign in to comment.