154
|
1 module stack where
|
|
2
|
|
3 pushSingleLinkedStack : Stack -> Data -> (Code : Stack -> ?) -> ?
|
|
4 pushSingleLinkedStack stack data next = next stack1
|
|
5 where
|
|
6 element = record {next = top stack; data = data}
|
|
7 stack1 = record {top = just element}
|
|
8
|
|
9
|
|
10 popSingleLinkedStack : Maybe ?? -> Data -> (Code : Stack -> (Maybe ??) -> ?) -> ?
|
|
11 popSingleLinkedStack stack data next with (top stack) =
|
|
12 ... | nothing = next stack nothing
|
|
13 ... | just a = next stack1 data1
|
|
14 where
|
|
15 data1 = data a
|
|
16 stack1 = record { top = (next a)}
|