Singleton-Filter-But-Preserving-Order

Run Settings
LanguageRaku
Language Version
Run Command
#!/usr/bin/env raku #| The program outputs the numbers that appear only once in the input - keeping the original order # example input #2 #1 #4 #3 #2 #1 # expected output for the example input #4 #3 # read all lines from standard input - we need it twice, hence we store it in an array my @numbers = $*IN.lines; # find numbers that appear only once my @singletons = @numbers.Bag.grep(*.value == 1).map(*.key); # print the single-occurrence numbers in their original order @numbers.grep( * ∈ @singletons ).join("\n").put
Editor Settings
Theme
Key bindings
Full width
Lines