Sunday, October 14, 2012

Language, language, language... I want to be a polyglot

I've tried many time to get Function Programming but I can't. Just learn some syntax then forgot all because it's very hard to get them if you don't really use them.

Of cause, everyone will argue, Haskell or a dialect of LISP?
Some answer can be found here: http://programmers.stackexchange.com/questions/18838/haskell-and-lisp-vs-haskell-or-lisp

Haskell like, Smalltalk. They are so pure, and you should learn them for learning many thing.

"Haskell and Lisp are two totally different beasts.
Haskell is kindof "pure functional programming in an ivory tower"
Lisp is kindof "code-is-data / data-is-code / make your own language constructs". You can manipulate your code in whatever way you can imagine.
They are very different. Both share the "functional programming" aspect, but that's really a tiny little common point compared to their differences. Just try them out and you will see how different they are!"

so go for haskell first, then lisp.
Happy coding!

One thing I hate about Haskell is its compile (ghc) is too heavy weight!

Saturday, October 13, 2012

[BASH] Count frequency of each letter in an English document

use only coreutils of Linux

first, convert all upper to lower by tr command, then grep with -o option, sort, uniq, then sort again!

hvn@lappy:~/Downloads$ tr '[:upper:]' '[:lower:]' <  prideandprejudice.txt | grep -o [a-z] | sort -nr | uniq -c | sort -nr
  71194 e
  48159 t
  42695 a
  41379 o
  38944 i
  38721 n
  34582 h
  33870 s
  33468 r
  22843 d
  22071 l
  15510 u
  15124 m
  14060 c
  13033 y
  12573 w
  12381 f
  10444 g
   9363 b
   8683 p
   5840 v
   3342 k
    970 j
    938 z
    867 x
    638 q