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

Finding mode in TXR Lisp:

  This is the TXR Lisp interactive listener of TXR 197.
  Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
  1> [group-by identity '(1 1 1 1 2 2 3 3 3 3 3 3 4)]
  #H(() (1 (1 1 1 1)) (2 (2 2)) (3 (3 3 3 3 3 3)) (4 (4)))
  2> [find-max *1]
  (4 4)
  3> [find-max *1 : len]
  (3 3 3 3 3 3 3)
  4> (car *3)
  3
All together:

  5> (car [find-max [group-by identity '(1 1 1 1 2 2 3 3 3 3 3 3 4)] : len])
  3
Build an anon function out of these steps using opip macro:

  6> (opip (group-by identity) (find-max @1 : len) car)
  #<intrinsic fun: 0 param + variadic>
Invoke it on the sequence:

  7> [*6 '(1 1 1 1 2 2 3 3 3 3 3 3 3 4)]
  3



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

Search: