Letter frequency: Difference between revisions

Content added Content deleted
(Added zkl)
(→‎{{header|TXR}}: Correct lang tags.)
Line 2,438: Line 2,438:
===Pattern Matching Plus Embedded Lisp===
===Pattern Matching Plus Embedded Lisp===


<lang lisp>@(do (defvar h (make-hash nil nil t)))
<lang txr>@(do (defvar h (make-hash nil nil t)))
@(collect :vars ())
@(collect :vars ())
@(coll :vars ())@\
@(coll :vars ())@\
Line 2,447: Line 2,447:
@(do (dohash (key value h)
@(do (dohash (key value h)
(format t "~a: ~a\n" key value)))</lang>
(format t "~a: ~a\n" key value)))</lang>

{{out}}


<pre>$ ./txr letterfreq.txr /usr/share/dict/words
<pre>$ ./txr letterfreq.txr /usr/share/dict/words
Line 2,459: Line 2,461:
===Just Embedded Lisp===
===Just Embedded Lisp===


<lang lisp>@(do (defun lazy-char-stream (s)
<lang txr>@(do (defun lazy-char-stream (s)
(let (ch) (gen (set ch (get-char s)) ch)))
(let (ch) (gen (set ch (get-char s)) ch)))