teaching machines

CS 330 Lecture 29 – Functional

April 15, 2015 by . Filed under cs330, lectures, spring 2015.

Agenda

TODO

Code

Hello.hs

import Data.Char

a = 7
-- a = 0 

-- initials :: [Char] -> [Char] -> [Char] -> [Char] 
initials fname mname lname = head fname : head mname : head lname : []

capitalize :: [Char] -> [Char]
capitalize s =
  if s == [] then
    []
  else 
    toUpper (head s) : capitalize (tail s)

capitalize2 s
  | s == [] = []
  | otherwise = toUpper (head s) : capitalize2 (tail s)

capitalize3 s
  case s of
    [] -> []
    (first:rest) -> toUpper first : capitalize2 rest

Haiku

on the science of naming things
“We’re out of letters
Greek’s used up. Hats and bars too.”
How math birthed CS