Sha256: e59b99ba98f47a314d21ef0df1b2ed3245675adeb1a3abf837e8eb66bb977741

Contents?: true

Size: 647 Bytes

Versions: 3

Compression:

Stored size: 647 Bytes

Contents

(declare empty-stack [A --> [stack B]])

(declare push [A --> [stack A] --> [stack A]])

(declare top [[stack A] --> A])

(declare pop [[stack A] --> [stack A]])

(define empty-stack
   _ -> (/.  X (if (or (= X pop) (= X top))
                        (error "this stack is empty~%")
                        (error "~A is not an operation on stacks.~%" X))))
                        
(define push
   X S -> (/. Y (if (= Y pop) 
                    S 
                   (if (= Y top) 
                       X 
                       (error "~A is not an operation on stacks.~%" Y)))))

(define top
   S -> (S top))

(define pop
   S -> (S pop))


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shen-ruby-0.12.1 shen/release/test_programs/stack.shen
shen-ruby-0.12.0 shen/release/test_programs/stack.shen
shen-ruby-0.11.0 shen/release/test_programs/stack.shen