Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help if you know ML, or SML: Thank you! 1.Define a function mymap1 with the same type and behavior as built-in map function but without

Help if you know ML, or SML: Thank you!

1.Define a function mymap1 with the same type and behavior as built-in map function but without using map. This should be one-line of code. Use foldr or foldl) (refer to problem Exercise 24 on page 147)

2. Define a function mymap2 with the same type and behavior as map. No map, foldr, or foldl can be used. (refer to problem Exercise 26 on page 147)

3. Write a function 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)

4. Write a function mylength fo type a list -> int that returns the length of a list. You cannot use the built-in length function. (refer to Exercise 11 on page 145)

5. Write a function max of type int list -> int that returns the largest element of a list of integers. Your function need not behave well if the list is empty.

result should be like this:

image text in transcribed

You should use mymap1 and mymap2 in problem 3, 4, and 5 if it is needed.

Standard ML of New Jersey v110.79 [built: Sun 0ct 4 14:45:06 2015] - use "CSCI461ProjThree.sml" lopening CSCI461ProjThree.sml] val mymap! = fn : ('a-> 'b) -> 'a list-> 'b list val nymap2 fn : ( 'a-> 'b) -> 'a list-> 'b list val ord list = fn : char list-> int list val nyLength = fn : 'a list-> int val maxlist = fn : int list-> int val it = () : unit -ord list [#"A", #"b", #"c"]; val it = [65,98,67] : int list - myLength [9, 1, 4, 2, 3, 8, 71; val it = 7 : int - maxList [8, 2, 5, 9, 4, 7, 1, 31 val it = 9 : int Standard ML of New Jersey v110.79 [built: Sun 0ct 4 14:45:06 2015] - use "CSCI461ProjThree.sml" lopening CSCI461ProjThree.sml] val mymap! = fn : ('a-> 'b) -> 'a list-> 'b list val nymap2 fn : ( 'a-> 'b) -> 'a list-> 'b list val ord list = fn : char list-> int list val nyLength = fn : 'a list-> int val maxlist = fn : int list-> int val it = () : unit -ord list [#"A", #"b", #"c"]; val it = [65,98,67] : int list - myLength [9, 1, 4, 2, 3, 8, 71; val it = 7 : int - maxList [8, 2, 5, 9, 4, 7, 1, 31 val it = 9 : int

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions