Skip to content

Instantly share code, notes, and snippets.

View mkohlhaas's full-sized avatar

Michael Kohlhaas mkohlhaas

View GitHub Profile
@mkohlhaas
mkohlhaas / crosswords.pl
Created July 23, 2020 11:12
Learn Prolog Now! Exercise 2.4
% crossword
word(astante,a,s,t,a,n,t,e).
word(astoria,a,s,t,o,r,i,a).
word(baratto,b,a,r,a,t,t,o).
word(cobalto,c,o,b,a,l,t,o).
word(pistola,p,i,s,t,o,l,a).
word(statale,s,t,a,t,a,l,e).
h1(H1,V1,V2,V3):-
// Built with IMPACT - impactjs.org
(function (window) {
"use strict";
Number.prototype.map = function (istart, istop, ostart, ostop) {
return ostart + (ostop - ostart) * ((this - istart) / (istop - istart));
};
Number.prototype.limit = function (min, max) {
return Math.min(max, Math.max(min, this));
};
Number.prototype.round = function (precision) {
module Ch05 where
import Prelude (Unit, type(~>), discard, negate, show, otherwise, (+), (-), (<), (>), (<=), (>=), (==), (/=), (<<<))
import Data.List (List(..))
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..), snd)
import Effect (Effect)
import Effect.Console (log)
flip :: ∀ a b c. (a -> b -> c) -> b -> a -> c
module Ch07a1 where
import Prelude (Unit, discard, (<>))
import Effect (Effect)
import Effect.Console (log)
-------------------- JS Primitives --------------------------------------------------------
foreign import ordIntImpl :: Ordering -> Ordering -> Ordering -> Int -> Int -> Ordering
foreign import eqIntImpl :: Int -> Int -> Boolean
module Ch07a2 where
import Prelude (Unit, discard, show, (==), (<=), (<), (>), (>=), ($))
import Data.Eq (class Eq)
import Data.Ord (class Ord)
import Data.Show (class Show)
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Effect (Effect)
import Effect.Console (log)
module Ch07b where
import Prelude (Unit, discard, show, ($), (<>), (==), (#))
import Data.Eq (class Eq)
import Data.Show (class Show)
import Data.Generic.Rep (class Generic)
import Data.Newtype (class Newtype)
import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow)
import Data.Int (fromString)
module Ch09 where
import Prelude (Unit, class Show, class Eq, discard, ($), show, (==), (&&))
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Console (log)
----------- Type Classes ---------------------------------------------------------------------------
module Ch11 where
import Prelude (Unit, class Semiring, class Ord, type (~>), discard, flip, negate, otherwise, show, zero, ($), (>), (+), (<>), (<<<))
import Data.Foldable (class Foldable, foldl, foldr, foldMap)
import Data.Semigroup.Foldable (class Foldable1, foldl1)
import Data.List (List(..), (:), singleton)
import Data.List.Types (NonEmptyList(..))
import Data.NonEmpty ((:|))
import Effect (Effect)
import Effect.Console (log)
module Ch13 where
import Prelude (Unit, class Eq, class Show, discard, flip, identity, show, ($), (/), (<>), (==), (*), (<<<))
import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Data.String.Common (toUpper)
import Effect (Effect)
import Effect.Console (log)
----------- Type classes ----------------------------------------------------------------------------------------------------------------------------------