CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 09:29:51 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=defa74940c175cadba10d38a30482d002d22b1dd84cbd0f188411e4f59ce7d7fa%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%221P_VPWisnbGjTeWsm7iL8mZiae4PL6bs%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cd55ddce6c5917-BLR
module HW1.T2 ( N (..) , nplus , nmult , nsub , nFromNatural , - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module HW1.T2
- ( N (..)
- , nplus
- , nmult
- , nsub
- , nFromNatural
- , nToNum
- , ncmp
- , nEven
- , nOdd
- , ndiv
- , nmod
- ) where
- import Numeric.Natural
- data N = Z | S N
- nplus :: N -> N -> N
- nplus Z n = n
- nplus (S n) m = S (nplus n m)
- nmult :: N -> N -> N
- nmult Z _ = Z
- nmult (S n) m = nplus m (nmult n m)
- nsub :: N -> N -> Maybe N
- nsub Z Z = Just Z
- nsub Z _ = Nothing
- nsub n Z = Just n
- nsub (S m) (S n) = nsub m n
- ncmp :: N -> N -> Ordering
- ncmp Z Z = EQ
- ncmp _ Z = GT
- ncmp Z _ = LT
- ncmp (S m) (S n) = ncmp m n
- nFromNatural :: Natural -> N
- nFromNatural 0 = Z
- nFromNatural n = S (nFromNatural (n - 1))
- nToNum :: Num a => N -> a
- nToNum Z = 0
- nToNum (S n) = nToNum n + 1
- nEven :: N -> Bool
- nEven Z = True
- nEven (S Z) = False
- nEven (S (S n)) = nEven n
- nOdd :: N -> Bool
- nOdd Z = False
- nOdd (S n) = nEven n
- ndiv :: N -> N -> N
- ndiv _ Z = error "Division by zero"
- ndiv n m
- | ncmp n m == LT = Z
- | otherwise = case nsub n m of
- Just result -> S (ndiv result m)
- Nothing -> Z
- nmod :: N -> N -> N
- nmod _ Z = error "Division by zero"
- nmod n m
- | ncmp n m == LT = n
- | otherwise = case nsub n m of
- Just result -> nmod result m
- Nothing -> Z
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 1 sec ago | 0.10 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ 1
JavaScript | 1 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 2 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ R
JavaScript | 3 sec ago | 0.24 KB
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 12 sec ago | 0.10 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ X
JavaScript | 12 sec ago | 0.24 KB
-
⭐⭐⭐ G2A Payment Exploit ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 12 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ T
JavaScript | 14 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand