home
/
code
/
hope.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8dad2fa
)
Amortize list traversal.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Fri, 15 Aug 2014 02:56:24 +0000
(22:56 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Fri, 15 Aug 2014 02:56:24 +0000
(22:56 -0400)
src/hope_list.erl
patch
|
blob
|
blame
|
history
diff --git
a/src/hope_list.erl
b/src/hope_list.erl
index
5ce527c
..
9ce451e
100644
(file)
--- a/
src/hope_list.erl
+++ b/
src/hope_list.erl
@@
-16,11
+16,11
@@
-spec unique_preserve_order(t(A)) ->
t(A).
unique_preserve_order(L) ->
-
Ap
pendIfNew =
+
Pre
pendIfNew =
fun (X, Xs) ->
case lists:member(X, Xs)
- of true -> Xs
- ; false ->
Xs ++ [X
]
+ of true ->
Xs
+ ; false ->
[X | Xs
]
end
end,
- lists:
foldl(AppendIfNew, [], L
).
+ lists:
reverse(lists:foldl(PrependIfNew, [], L)
).
This page took
0.024322 seconds
and
4
git commands to generate.