December 2006 Blog Posts

ROT13 in F#

Over on his blog, Andrei Formiga has a series of post on implementing ROT13 in F# and Haskell. http://codemiscellany.blogspot.com/2006/12/rot13-in-f.html http://codemiscellany.blogspot.com/2006/12/rot13-in-haskell.html http://codemiscellany.blogspot.com/2006/12/rot13-in-f-revisited.html http://codemiscellany.blogspot.com/2006/12/still-more-rot13.html   I like is implementation using library functions that don’t yet exist in F#, such as drop and zip. Here is the implementation itself, stripped of the extra library functions he had to implement, for the original see the above links.   #light let rot13 s =     let letters = ['a' .. 'z']    let transp = zip letters ((drop 13 letters) @ (take 13 letters))    let rotchar c = List.assoc c transp    strmap rotchar s   The clever bit of...