Question: Implement a function that mimics built-in map function in SML. Apply foldr, foldl, and map to solve some problem with a single line of code.

Implement a function that mimics built-in map function in SML.

Apply foldr, foldl, and map to solve some problem with a single line of code.

3. Write a function named ordlist of type char list -> int list that take a list of characters and returns the list of integer codes of those characters. For example, if you evaluate ordlist [#A, #b, #C] you should get [65, 98, 67]. (Refer to Exercise 2 on page 144.)

Implement a function that mimics built-in map function in SML. Apply foldr,

$ sml Standard ML of New Jersey (64-bit) v110.99 [built: Thu Dec 24 11:47:23 2020] - use "ProjectThree.sml"; [opening ProjectThree.sml] val mymap - fn: ('a -> 'b) -> 'a list -> 'b list val mymap2 - fn: ('a -> 'b) -> 'a list -> 'b list val mylength - In: 'a list -> int val ordlist = fn ; char list -> int list val max - En ! int list -> int val it = () : unit - ordlist [#"A", "B", "C"); val it - [65,66,67] : int list - mylength 0; val it = 0; int - mylength [9, 1, 4, 2, 3, 8, 7]; val it - 7 : int - max [8, 2, 5, 9, 4, 7, 1, 3]; val it = 9; int - max (-1,5,0]; val it = 5; int $ sml Standard ML of New Jersey (64-bit) v110.99 [built: Thu Dec 24 11:47:23 2020] - use "ProjectThree.sml"; [opening ProjectThree.sml] val mymap - fn: ('a -> 'b) -> 'a list -> 'b list val mymap2 - fn: ('a -> 'b) -> 'a list -> 'b list val mylength - In: 'a list -> int val ordlist = fn ; char list -> int list val max - En ! int list -> int val it = () : unit - ordlist [#"A", "B", "C"); val it - [65,66,67] : int list - mylength 0; val it = 0; int - mylength [9, 1, 4, 2, 3, 8, 7]; val it - 7 : int - max [8, 2, 5, 9, 4, 7, 1, 3]; val it = 9; int - max (-1,5,0]; val it = 5; int

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!