From 0e828db9689a06f1ebbdf338c0e796ec0495d526 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 2 Dec 2014 00:41:12 +1100 Subject: Function to replace the GNode on top of the IP stack --- src/Grasp/IP.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Grasp/IP.hs b/src/Grasp/IP.hs index 6a4d452..294c92d 100644 --- a/src/Grasp/IP.hs +++ b/src/Grasp/IP.hs @@ -6,7 +6,8 @@ module Grasp.IP ( isEmpty, peek, push, - pop + pop, + shift ) where @@ -39,5 +40,8 @@ push :: GNode -> IP -> IP push n (IP p) = IP (n:p) pop :: IP -> IP -pop (IP p) = if (length p == 0) then IP p else IP (tail p) +pop (IP p) = if (length p == 0) then empty else IP (tail p) + +shift :: GNode -> IP -> IP +shift n (IP p) = if (length p == 0) then empty else IP (n:(tail p)) -- cgit