Arc Forumnew | comments | leaders | submitlogin
1 point by rincewind 5816 days ago | link | parent

  (def keep-cols (cols tabl) ;for one row
     (map [let nr -1 (keep [some (++ nr) cols] _)] tabl))

  (def get-cols (cols tabl) ;table with selected columns
      (withs ((head . rows) tabl
              colnrs (rem nil (map [pos _ head] cols))
              filtered-rows (keep-cols colnrs rows))
        (cons cols filtered-rows)))

  ;test
  (get-cols '(foo baz) '((foo bar baz) ;header
                         (bla bla spam)
                         (eggs ham bacon) 
                         (lorem ipsum test)))


1 point by thaddeus 5815 days ago | link

That's much nicer code than mine :)

I'm going to step through some of the syntax; I haven't been using: map, [], or "." yet.

Thanks, T.

-----