News for hackers. Stuff that matters.
Re:The Expressive C++17 Coding Challenge in D by kazinator on Wednesday February 14, 2018 @02:39PM (#16378672)
TXR Lisp, using standard awk macro:

  (awk (:inputs *stdin*)                                                          
       (:set fs "," ofs ",")                                                      
       (:let pos (name [*args* 0]) (rplc [*args* 1]))                             
       ((= nr 1) (set pos (pos name f)))                                          
       ((> nr 1) (set [f pos] rplc))                                              
       (t (prn)))
Missing args -> pass through:

  $ txr solve.tl < data
  name,surname,city,country
  Adam,Jones,Manchester,UK
  Joe,Doe,Cracow,Poland
  Michael,Smith,Paris,France
  Alex,McNeil,Gdynia,Poland
With args:

  $ txr solve.tl city London < data
  name,surname,city,country
  Adam,Jones,London,UK
  Joe,Doe,London,Poland
  Michael,Smith,London,France
  Alex,McNeil,London,Poland
We need (:inputs stdin) so that awk takes its input from standard input rather than processing the city London arguments as input sources.

There are no comments on this comment yet.