Allegro CL Certification Program Lisp Programming Series Level I - - PowerPoint PPT Presentation

allegro cl certification program
SMART_READER_LITE
LIVE PREVIEW

Allegro CL Certification Program Lisp Programming Series Level I - - PowerPoint PPT Presentation

Allegro CL Certification Program Lisp Programming Series Level I Session 1.3.5 Homework 7/11/2003 1 Question What is the difference between the following expressions (and what will the interpreter do)? A 'A " A"


slide-1
SLIDE 1

7/11/2003 1

Allegro CL Certification Program

Lisp Programming Series Level I Session 1.3.5 Homework

slide-2
SLIDE 2

7/11/2003 2

Question

  • What is the difference between the

following expressions (and what will the interpreter do)?

– A – 'A – " A" – #\A

slide-3
SLIDE 3

7/11/2003 3

List Anatomy

  • Draw the following lists as "box and pointer"

diagrams of cons cells – (rose marigold petunia) – ((rose 1) (marigold 7) (petunia 12)) – ((nitrogen . 10) (potassium . 5) (phosphorus . 5))

Note: last bullet has dotted lists (not decimals)

slide-4
SLIDE 4

7/11/2003 4

Strings

  • Write a function that finds an HTML tag:

– (find-tag "<b>Test.</b>") => "b"

  • Write a version that finds multiple tags:

– (find-tag "<b>Test.</b><i>Test.</i>") =>("b" "i")

  • Write a function that finds the contents of

an HTML tag. Pass the tag of interest as an argument.

– (get-tag-contents "b" "<b>Test.</b>") => "Test."

slide-5
SLIDE 5

7/11/2003 5

Arrays

  • Write a function that takes a vector of

numbers and doubles them “in place”

– (setq a (vector 123)) – (double a) – a => #(2 4 6)

slide-6
SLIDE 6

7/11/2003 6

Symbols

  • Write a function that takes a string as input

and returns all the words in the string as symbols

  • Use your function to read a file and return a

count of the occurrence of each word in the form of an association list

  • Sort the association list in descending order
  • f most common to least common words
slide-7
SLIDE 7

7/11/2003 7

Files

  • Write a function that takes this list as input:

(html (body (h1 "Lisp") "Hello from lisp"))

  • And produce a text file containing:

<html> <body> <h1>Lisp<h1> Hello from lisp </body> </html>