annotate final_pre/src/AgdaStackImpl.agda.replaced @ 11:ef87093f92d4

add pdf
author e155702
date Sun, 17 Feb 2019 17:13:37 +0900
parents 0e8b9646d43f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
1 record SingleLinkedStack {n : Level } (a : Set n) : Set n where
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
2 field
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
3 top : Maybe (Element a)
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
4 open SingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
5
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
6 pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} @$\rightarrow$@ SingleLinkedStack Data @$\rightarrow$@ Data @$\rightarrow$@ (Code : SingleLinkedStack Data @$\rightarrow$@ t) @$\rightarrow$@ t
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
7 pushSingleLinkedStack stack datum next = next stack1
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
8 where
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
9 element = cons datum (top stack)
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
10 stack1 = record {top = Just element}
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
11
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
12 -- Basic stack implementations are specifications of a Stack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
13
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
14 singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ StackMethods {n} {m} a {t} (SingleLinkedStack a)
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
15 singleLinkedStackSpec = record {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
16 push = pushSingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
17 ; pop = popSingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
18 ; pop2 = pop2SingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
19 ; get = getSingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
20 ; get2 = get2SingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
21 ; clear = clearSingleLinkedStack
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
22 }
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
23
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
24 createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ Stack {n} {m} a {t} (SingleLinkedStack a)
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
25 createSingleLinkedStack = record {
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
26 stack = emptySingleLinkedStack ;
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
27 stackMethods = singleLinkedStackSpec
0e8b9646d43f add final_pre
e155702
parents:
diff changeset
28 }