Question 24 Translate the following code so that only tail function calls are made using continuation passing. If you use a language that is not ML, please indicate which language. fun insert(x, nil) = [x] | insert(x, y1::y2) = if (x = y1) then y1:y2 else y1:insert(x, y2); fun process(x,y) = if (x > 100) then 100 :: process(x-100,y) else insert(x,y); Edit View Insert Format Tools Table | B IU A v 2v T²v: 12pt v Paragraph v

icon
Related questions
Question
Question 24
Translate the following code so that only tail function calls are made using continuation passing. If
you use a language that is not ML, please indicate which language.
fun insert(x, nil) = [x]
| insert(x, y1::y2) = if (x = y1) then y1:y2 else y1:insert(x, y2);
fun process(x,y) = if (x > 100) then 100 :: process(x-100,y) else insert(x,y);
Edit View Insert Format Tools Table
|
B IU A
v 2v T²v:
12pt v Paragraph v
Transcribed Image Text:Question 24 Translate the following code so that only tail function calls are made using continuation passing. If you use a language that is not ML, please indicate which language. fun insert(x, nil) = [x] | insert(x, y1::y2) = if (x = y1) then y1:y2 else y1:insert(x, y2); fun process(x,y) = if (x > 100) then 100 :: process(x-100,y) else insert(x,y); Edit View Insert Format Tools Table | B IU A v 2v T²v: 12pt v Paragraph v
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer