Skip to content

Instantly share code, notes, and snippets.

@kiyoka
Created August 11, 2012 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiyoka/3323850 to your computer and use it in GitHub Desktop.
Save kiyoka/3323850 to your computer and use it in GitHub Desktop.
example #2 filter with generator
#!/bin/sh
:; #-*- mode: nendo; syntax: scheme -*-;;
:; exec /usr/local/bin/nendo $0 $*
;; print the peek memory usage of this process.
(define (print-peek-memory)
(with-open "|cat /proc/#{Process.pid}/status"
(lambda (f)
(STDERR.puts (+ "=> " (car (to-list (f.readlines.grep #/vmpeak/i))))))))
(define (main argv)
(with-open
"bigdata.txt"
(lambda (f)
(let* ((lines (f.lines))
(lst (map
(lambda (line)
(+ "<" line.chomp ">"))
lines)))
(for-each print lst))))
(print-peek-memory))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment