Non- Destructive:
ilist double_copy(ilist x) {
if (x==NULL) return NULL;
ilist head = malloc(sizeof(struct ilist_node));
head ->first = x->first * 2;
head ->rest = NULL;
ilist prev = head;
for (ilist a = x->rest; a != NULL; a = a->rest) {
ilist tmp = malloc(sizeof(struct ilist_node));
tmp->first = a->first * 2;
tmp->rest = NULL;
prev ->rest = tmp;
prev = tmp;
}
return head;
}



Destructive:
ilist double_destructive(ilist x) {
for (ilist a = x; a != NULL; a = a->rest) {
a->first = a->first * 2;
}
return x;
}