fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 119: Deduplicate list
Idiom # 119: Deduplicate list
See
programming-idioms.org
:
Code
# preserving order # x := for r list String := nil, if e ∈ s then r else cons e r s := container.set_of_ordered (Sequence String).empty, s.add e e in x else r.reverse # not preserving order # x := container.set_of_ordered x
What are effects?
Running Example
ex119 is # preserving order # x := [ $"b", "a", "b", "c" ] x1 := for r list String := nil, if e ∈ s then r else cons e r s := container.set_of_ordered (list String).empty, s.add e e in x else r.reverse say x1 # not preserving order # x2 := [ "b", "a", "b", "c" ] x3 := container.set_of_ordered x2 say x3
What are effects?
last changed: 2024-07-01
next: Idiom # 120: Read integer from stdin