Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function (in standar ml) permu: int -> int list list to generate the permutation of the identity list from 1 to n. permu(2)=>[[1,2],[2,1]].

Write a function (in standar ml) permu: int -> int list list to generate the permutation of the identity list from 1 to n. permu(2)=>[[1,2],[2,1]]. permu(3)=>[[1,2,3],[2,1,3],[2,3,1],[1,3,2],[3,1,2],[3,2,1]]

The key is to implement a function interleave: (int * int list) -> int list list which takes an integer and a list of integers and returns a list containing the set of lists resulting from the insertion of the integer in all possible positions of the original list. For example,

interleave(4,[1,2,3])=[4,1,2,3],[1,4,2,3],[1,2,4,3],[1,2,3,4]]

You have to use higher order function approach to implement interleave function

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

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

2. How will the team select a leader?

Answered: 1 week ago