You don’t like instance functions?
stdin
.byLine(KeepTerminator.yes)
.uniq
.map!(a => a.idup)
.array
.sort
.copy(stdout.lockingTextWriter());
I would like to emphasize that this is a personal preference. No need to continue to bash me over it.I prefer Elixir's |> operator, if you want an example of something I prefer.
print join '',
sort { $a cmp $b }
grep { !$seen{$_}++ } # = uniq
<STDIN>; stdin
|> byLine(yes)
|> uniq
|> map(a => aidup)
|> array
|> sort
|> copy(stdout)
I’m sorry if you took it as bashing. It’s mere curiosity as I’ve never seen that preference before."map(a => aidup)" caught me by surprise, too. Would Elixir do such a thing?
IO.stream(:stdio, :line)
|> Stream.map(&String.trim_trailing/1)
|> Enum.uniq()
|> Enum.map(&String.duplicate(&1, 1))
|> Enum.sort()
|> Enum.each(&IO.puts/1)
This is not equivalent in style or presentation to: stdin
.byLine(KeepTerminator.yes)
.uniq
.map!(a => a.idup)
.array
.sort
.copy(stdout.lockingTextWriter());
Personally, I find the D version visually unappealing (and confusing), especially the way "stdin" sits alone on its own line, followed by a sequence of indented method calls. The excessive use of dots combined with the indentation structure makes it look, to me, rather awkward.That is just my own opinion.