teaching machines

CS 330 Lecture 7 – Regex Cont’d

February 9, 2015 by . Filed under cs330, lectures, spring 2015.

Agenda

TODO

What Does This Do?

  1. show
  2. show
  3. show
  4. show

Code

arithmetic.txt

Day 1: the number of bunnies was {{ 5 }}.

Day 2: the number of bunnies was {{ 5 * 2 }}.

Day 3: the number of bunnies was {{ 5 ** 40 }}.

calc.rb

#!/usr/bin/env ruby

raw = IO.read(ARGV[0])

cooked = raw.gsub(/\{\{(.*?)\}\}/) do |match|
  # puts match 
  # puts $1 
  eval($1)
end

puts cooked

music.rb

#!/usr/bin/env ruby

notes = "A B C C# Db A B G Ab Bb C# Db G#"

cooked = notes.gsub(/A(?!b|#)/, 'G')

puts notes
puts cooked

Haiku

show