This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <pthread.h> | |
#include <string.h> | |
#define DEBUG | |
#ifdef DEBUG | |
#define PRINT(...) printf(__VA_ARGS__); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Visibility where | |
import Data.List (sortBy, minimumBy) | |
import Data.Ord | |
import Data.Maybe (mapMaybe) | |
import Diagrams (Diagram, P2, (#), Located) | |
import qualified Diagrams as Diag | |
import Diagrams.Backend.Rasterific (Rasterific) | |
import qualified Diagrams.Backend.Rasterific as Rast | |
import Data.Colour (Colour) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Node = Value Int | List [Node] | Sequence [Node] | |
steps :: Node -> [[Int]] | |
steps (Value x) = [[x]] | |
steps (List ns) = case substeps of | |
[] -> [] | |
(x : xs) -> x ++ concat (zipWith prepend lastStates xs) | |
where substeps = map steps ns | |
lastStates = scanl1 (++) $ map last substeps | |
prepend pref ss = map (pref ++) ss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box :: Bool -> Angle Double -> Diagram SVG | |
box on angle = ((square (sqrt 2) `clipTo` rotate angle pattern) <> base) # lwO 1.5 | |
where base = square (sqrt 2) # fc (if on then peachpuff else turquoise) | |
chromosome :: [Bool] -> Angle Double -> Diagram SVG | |
chromosome list angle = hcat $ map (pad 1.1 . (`box` angle)) list | |
first :: Diagram SVG | |
first = chromosome [True, False, True] (1/8 @@ turn) | |
||| padX 1.3 (chromosome [True, False] (1/8 @@ turn)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lns :: Diagram SVG | |
lns = Diag.fromOffsets [Diag.unitX # Diag.rotateBy (1/8)] | |
pattern :: Diagram SVG | |
pattern = Diag.gridCat $ replicate 64 lns | |
circle :: Diagram SVG | |
circle = Diag.circle 4 `Diag.clipBy` pattern | |
where circleClip = Diag.circle 4 # Diag.translate (Diag.r2 (4, 4)) # Diag.showOrigin :: Diagram SVG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sample :: Presentation | |
sample = | |
emptyPresentation { | |
slides = [ | |
Slide [ | |
Header 1 "Genetski algoritmi", | |
Header 2 "Križanja" | |
], | |
Slide [ | |
Header 2 "Sadržaj", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Map (Map) | |
import qualified Data.Map as Map | |
instance (Ord k, Monoid k) => Applicative (Map k) where | |
pure = Map.singleton mempty | |
f <*> x = Map.fromList [(mappend fk xk, f Map.! fk $ x Map.! xk) | fk <- Map.keys f, xk <- Map.keys x] | |
instance (Ord k, Monoid k) => Monad (Map k) where | |
return = pure | |
m >>= f = Map.fromList $ do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MultiWayIf, MultiParamTypeClasses, FunctionalDependencies #-} | |
module AStar where | |
import Control.Monad.State | |
import Data.Set (Set) | |
import qualified Data.Set as Set | |
import PriorityQueue (PriorityQueue) | |
import qualified PriorityQueue as Prio | |
class Ord s => AStarState s m | s -> m where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PriorityQueue where | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
data Unique = U | |
instance Eq Unique where | |
U == U = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PriorityQueue where | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
data Unique = U | |
instance Eq Unique where | |
U == U = False |