regular expressions
play

regular expressions any character is a regexp Kleene * matches - PowerPoint PPT Presentation

how hard can it be? algorithms: what can they do? what cant they do? Saturday, 3 December 2011 regular expressions any character is a regexp Kleene * matches itself if R and S are regexps, so is RS matches a


  1. how hard can it be? algorithms: • what can they do? • what can’t they do? Saturday, 3 December 2011

  2. regular expressions • any character is a regexp Kleene * • matches itself • if R and S are regexps, so is RS • matches a match for R followed by a match for S • if R and S are regexps, so is R|S • matches any match for R or S (or both) • if R is a regexp, so is R* • matches Stephen Kleene 1909-1994 any sequence of 0 or more matches for R Saturday, 3 December 2011

  3. http://xkcd.com/ Saturday, 3 December 2011

  4. algorithms in three easy parts • giving instructions • sequence, parameters • conditionals, iteration, recursion • needles in haystacks • hard to find; easy to recognise • some things are impossible • “I never tell the truth” Saturday, 3 December 2011

  5. sequence • separate four eggs • beat the whites • ... Saturday, 3 December 2011

  6. parametrisation • separate three eggs • beat the whites • ... Saturday, 3 December 2011

  7. parametrisation • separate n eggs • beat the whites • ... Saturday, 3 December 2011

  8. conditional if your potatoes are large • cut them into bite-sized pieces Saturday, 3 December 2011

  9. iteration • beat until the whites form stiff peaks Saturday, 3 December 2011

  10. recursion: sourdough • To make sourdough • take your sourdough out of the fridge • add a cup of warm water and a cup of flour to the bowl • leave to prove for eight hours • put half of the mixture in the fridge • use the other half to make bread Saturday, 3 December 2011

  11. sourdough bread • Ingredients • Method • mix all ingredients adding • sourdough starter flour until you have a • unbleached flour stiff dough • 2 tablespoons of olive oil • repeat twice or softened margarine • knead well • 4 teaspoons of sugar • leave to rise • 2 teaspoons of salt • form into a loaf and bake Saturday, 3 December 2011

  12. non-termination beat the milk until it forms stiff peaks Saturday, 3 December 2011

  13. algorithms in three easy parts • giving instructions • sequence, parameters • conditionals, iteration, recursion • needles in haystacks • hard to find; easy to recognise • some things are impossible Saturday, 3 December 2011

  14. Saturday, 3 December 2011

  15. Saturday, 3 December 2011

  16. Saturday, 3 December 2011

  17. Saturday, 3 December 2011

  18. maze generator Saturday, 3 December 2011

  19. Saturday, 3 December 2011

  20. algorithms in three easy parts • giving instructions • sequence, parameters • conditionals, iteration, recursion • needles in haystacks • hard to find; easy to recognise • some things are impossible Saturday, 3 December 2011

  21. Saturday, 3 December 2011

  22. circular reference • A: statement B is true • B: statement A is false Saturday, 3 December 2011

  23. self reference • A: statement A is false • E: statement E is true Escher, Hands Saturday, 3 December 2011

  24. exercise Albert says "Everything Caroline says is true" Betty says "Everything I say is false" Caroline says "Everything David says is true" David says "Everything Caroline says is false" Who is the only person who can be telling the truth? This is a sample question for the Cambridge admissions test for philosophy. Saturday, 3 December 2011

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend