logo CodeStepByStep logo

stutter

Language/Type: ML lists
Author: Melissa Hovik (on 2018/01/19)

Define a function named stutter that takes a list of integers and as a parameter and returns a new list with each integer in the passed list duplicated, preserving order.

For example, stutter([0, 1, 42, 2]) should return [0, 0, 1, 1, 42, 42, 2, 2]. If passed an empty list, the function should return an empty list.

Your function must have the following signature:

val stutter = fn : int list -> int list
Type your ML solution code here:

This is a function exercise. Write a ML function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.