Skip to content

Instantly share code, notes, and snippets.

module Main
isZ : Nat -> Bool
isZ Z = True
isZ _ = False
main : IO ()
main = do
print $ fromIntegerNat (-1)
print $ isZ $ fromIntegerNat (-1)
@PeterHajdu
PeterHajdu / readme.md
Created August 6, 2018 07:59
small app

Small app

@PeterHajdu
PeterHajdu / Sdl.hs
Last active August 20, 2017 15:33
space
{-# LANGUAGE OverloadedStrings #-}
module Sdl where
import Control.Monad (when)
import qualified SDL
import SDL.Vect
import SDL (($=))
import Foreign.C.Types
*agdai
MAlonzo
*.ibc
*.idr~
[pg/etext92/carol10.txt]
A CHRISTMAS CAROL
by Charles Dickens
I have endeavoured in this Ghostly little book,
to raise the Ghost of an Idea, which shall not put my
readers out of humour with themselves, with each other,
with the season, or with me. May it haunt their houses
import Control.Monad (replicateM)
import System.Random
import Test.QuickCheck
-- Exercise 1
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
@PeterHajdu
PeterHajdu / shape.erl
Last active February 23, 2017 16:11
erlang homework 1
-module(shape).
-export([area/1, perimeter/1, bits/1]).
area({rectangle,{_, _}, W, H}) when (0<W) and (0<H) -> W*H;
area({circle,{_, _}, R}) when (R>0) -> R*R*math:pi();
area({triangle,A, B, C}) when (A>0) and (B>0) and (C>0) -> heron(A, B, C).
heron(A,B,C) ->
S = (A + B + C)/2,
math:sqrt(S*(S-A)*(S-B)*(S-C)).
@PeterHajdu
PeterHajdu / hsp.hs
Last active January 23, 2017 16:40
test basics in haskell
module Main where
import Test.Hspec
import Test.QuickCheck
sqr :: Integer -> Integer
sqr n = n * n
squareNumberIsGreaterOrEqualToZero :: Integer -> Bool
squareNumberIsGreaterOrEqualToZero n = sqr n >= 0
@PeterHajdu
PeterHajdu / cis194_02.hs
Last active January 29, 2017 15:26
cis194_week2
{-# LANGUAGE OverloadedStrings #-}
import CodeWorld
import Data.Foldable
character, wall, ground, storage, box :: Picture
wall = colored (grey 0.4) (solidRectangle 1 1)
ground = colored yellow (solidRectangle 1 1)
storage = solidCircle 0.3 & ground
box = colored brown (solidRectangle 1 1)
character = colored green $ solidCircle 0.2 & translated 0.2 0 (solidCircle 0.1)