Slide Show Demo
A wiki page — and a slide show too?
Just export this page as S5 (in the sidebar). Or click here to view it as a slide show now.
Second slide: A list
- one
- two
- buckle my shoe
Fourth slide: some (poignant) ruby
require 'wordlist'
# Get evil idea and swap in code words
print "Enter your new idea: "
idea = gets
code_words.each do |real, code|
idea.gsub!( real, code )
end
# Save the jibberish to a new file
print "File encoded. Please enter a name for this idea: "
idea_name = gets.strip
File::open( "idea-" + idea_name + ".txt", "w" ) do |f|
f << idea
end
Fifth slide: No, Learn You a Haskell
import System.IO
main = do
handle <- openFile "girlfriend.txt" ReadMode
contents <- hGetContents handle
putStr contents
hClose handle
Running it, we get the expected result:
$ runhaskell girlfriend.hs
Hey! Hey! You! You!
I don't like your girlfriend!
No way! No way!
I think you need a new one!
Seventh Slide … for Great Good
-- Let's use a fold to implement searching a list for a sublist.
search :: (Eq a) => [a] -> [a] -> Bool
search needle haystack = foldl length_test False (tails haystack)
where length_test bool x =
if take needle_length x == needle then True else bool
needle_length = length needle
declaration :: String
declaration = "We hold these truths to be self-evident, " ++
"that all men are created equal"
Here we get the result:
ghci> search "elf" declaration
True
ghci> search "eat" declaration
True
Eighth Slide: some math?
With some inline: , and some displayed:
Doesn’t work yet in the S5 slide show, only plain webpages — need to add a link to jsMath!

