Question: Standard ML: An append list is a (simple) implementation of the list abstract data type that makes construction cheap (O(1)), but makes destruction expensive (O(n)).

Standard ML: An append list is a (simple) implementation of the list abstract data type that makes construction cheap (O(1)), but makes destruction expensive (O(n)). The 'a alistNN and 'a alist types are defined as follows:

datatype 'a alistNN = Sing of 'a | Append of 'a alistNN * 'a alistNN

datatype 'a alist = Nil | NonNil of 'a alistNN

The 'a alistNN type represents the non-nil append lists, while the 'a alist type represents arbitrary (nil or non-nil) append lists.

Here is what I have define for the function:

fun alistAppend (xs: 'a alist, ys: 'a alist): 'a alist =

case xs of

Nil => ys

| _ => NonNil (Append (xs,ys));

I'm getting "! Unbound type constructor: alist". I know the error is because i am not wrapping the NonNil correctly, anyone know how to resolve this problem?

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!