Hacker News new | past | comments | ask | show | jobs | submit login

Using TXR Lisp, obtain the list of words in /etc/fstab on a Ubuntu 18 system, sort them to get identical words into groups which are represented as sublists, then sort by descending length of sublist (i.e. frequency), take the top ten, and turn that into word-frequency pairs:

  This is the TXR Lisp interactive listener of TXR 232.
  Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
  1> [(opip (open-file "/etc/fstab")
            (record-adapter #/[^A-Za-z]+/)
            get-lines
            sort-group
            (sort @1 greater len)
            (take 10)
            (mapcar [juxt car len]))]
  (("defaults" 5) ("a" 3) ("dev" 3) ("ext" 3) ("home" 3) ("opt" 3)
   ("UUID" 2) ("c" 2) ("d" 2) ("e" 2))
Pretty print the list obtained from prompt 1:

  2> (mapdo (do put-line `@(car @1) -> @(cadr @1)`) *1)
  defaults -> 5
  a -> 3
  dev -> 3
  ext -> 3
  home -> 3
  opt -> 3
  UUID -> 2
  c -> 2
  d -> 2
  e -> 2
  nil



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: