mirror of
https://github.com/urbit/shrub.git
synced 2024-12-30 15:44:03 +03:00
add decrement example to UntypedLambda
This commit is contained in:
parent
c966f98a0f
commit
7d4ab2ceb9
@ -3,7 +3,7 @@ module UntypedLambda where
|
|||||||
import ClassyPrelude
|
import ClassyPrelude
|
||||||
|
|
||||||
import Bound
|
import Bound
|
||||||
import Control.Monad.Writer
|
import Control.Monad.Writer hiding (fix)
|
||||||
import Data.Deriving (deriveEq1, deriveOrd1, deriveRead1, deriveShow1)
|
import Data.Deriving (deriveEq1, deriveOrd1, deriveRead1, deriveShow1)
|
||||||
import qualified Data.Function as F
|
import qualified Data.Function as F
|
||||||
import Data.List (elemIndex)
|
import Data.List (elemIndex)
|
||||||
@ -307,6 +307,10 @@ posIn i n
|
|||||||
copy :: Ord a => Exp a -> Nock
|
copy :: Ord a => Exp a -> Nock
|
||||||
copy = copyToNock . toCopy
|
copy = copyToNock . toCopy
|
||||||
|
|
||||||
|
-- | Decrements its argument.
|
||||||
|
decrement :: Exp String
|
||||||
|
decrement = lam "a" $ App (fix "f" $ lam "b" $ Ift (Eql (Var "a") (Suc (Var "b"))) (Var "b") (App (Var "f") (Suc (Var "b")))) (Atm 0)
|
||||||
|
|
||||||
-- x. y. x
|
-- x. y. x
|
||||||
-- old: [8 [1 0] [1 8 [1 0] [1 0 30] 0 1] 0 1]
|
-- old: [8 [1 0] [1 8 [1 0] [1 0 30] 0 1] 0 1]
|
||||||
-- =+ 0 =
|
-- =+ 0 =
|
||||||
|
Loading…
Reference in New Issue
Block a user