On this page:
compose-func
flatten
flatten-foldr
bucket
tree-map
add-last-name

2.5 Higher-order Functions

You must complete this assignment by yourself.

You must submit this in an archive named "hof.zip".

You must submit this in a file named "hof.ss".

Develop the following functions and datatypes in the Intermediate Student language.

Rewrite check-range1, check-range, convert, average-price, convertFC, and eliminate-exp from the Lists and Trees assignment using map, filter, foldl, or foldr.

(compose-func after before)  (alpha . -> . gamma)
  after : (beta . -> . gamma)
  before : (alpha . -> . beta)
Returns the composition of before and after.

(flatten lolon)  (listof number?)
  lolon : (listof (listof number?))
Produces a list of all the numbers in the elements of lolon.

Don’t use foldr.

For example, (flatten (list (list 1 2) (list 3 4 5) (list 6))) returns (list 1 2 3 4 5 6).

(flatten-foldr lolon)  (listof number?)
  lolon : (listof (listof number?))
Produces a list of all the numbers in the elements of lolon.

Use foldr.

(bucket lon)  (listof (listof number?))
  lon : (listof number?)
Returns a list of sublists of adjacent equal numbers.

Use foldr.

For example, (bucket (list 1 1 2 2 2 3 1 1 1 2 3 3)) returns (list (list 1 1) (list 2 2 2) (list 3) (list 1 1 1) (list 2) (list 3 3)).

(tree-map f tree)  (or/c unknown? person?)
  f : (string? . -> . string?)
  tree : (or/c unknown? person?)
Returns a tree where f has been applied to every person’s name in tree.

(add-last-name tree lname)  (or/c unknown? person?)
  tree : (or/c unknown? person?)
  lname : string?
Returns a tree where lname has been appended to every person’s name in tree.

You should use tree-map and string-append.