This file contains 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 Main | |
import Data.Vect | |
import Effects | |
import Effect.Exception | |
import Effect.State | |
ComputeResult : (n ** Fin n) -> List EFFECT | |
ComputeResult (l ** _) = [EXCEPTION String, STATE (Vect l String)] |
This file contains 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.List | |
%default total | |
data PathComp : Type where | |
Empty : String -> PathComp | |
Printable : (t : Type) -> (t -> String) -> PathComp | |
Str' : PathComp | |
Str' = Printable String id |
This file contains 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
|||build a type signature out of a list of types | |
||| e.g.: `ListToSig [String, Int, Int]` returns String -> Int -> Int -> String | |
ListToSig : List Type -> Type | |
ListToSig [] = String | |
ListToSig (x :: xs) = x -> ListToSig xs | |
||| returns a function that builds a string from the arguments given to it | |
||| e.g.: `listToFunc [(String, show), (Int, show)] ""` returns a function f : String -> Int -> String | |
||| and when applied with input `f "hello" 3` gives "hello.3." |
This file contains 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
%default total | |
data Prop = Var String | |
| Not Prop | |
| And Prop Prop | |
| Or Prop Prop | |
| Impl Prop Prop | |
| Equiv Prop Prop | |
data Lit = Stmt String | Neg String |
This file contains 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
%default total | |
data Prop = Var String | |
| Not Prop | |
| And Prop Prop | |
| Or Prop Prop | |
| Impl Prop Prop | |
| Equiv Prop Prop | |
data Lit = Stmt String | Neg String |
This file contains 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.Vect | |
data Ast a = ASTLeaf a | NonASTLeaf a (Vect k $ Ast a) | |
data TypedAst : Type where | |
LLeaf : (a : String) -> TypedAst | |
NonTLeaf : (a : String) -> Vect k TypedAst -> TypedAst | |
Op : Type | |
data IR = IRLeaf Op | NonLeaf Op (Vect k IR) |
This file contains 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
public static Function<List<Float>, List<Float>> sobelDoubleConvolution(int width, int height) { | |
int[][] hSobel = {{0, 1, 0}, {0, 0, 0}, {0, -1, 0}}; | |
int[][] vSobel = {{0, 0, 0}, {1, 0, -1}, {0, 0, 0}}; | |
ImageTransformation<Float, Float> vertical = ImageTransformation.convolutionTransformation(vSobel, 3, width, height); | |
ImageTransformation<Float, Float> horizontal = ImageTransformation.convolutionTransformation(hSobel, 3, width, height); | |
return vertical.mergeWith(horizontal, MyList::zip) | |
.andThen(ls -> ls.parallelStream().map(Convolution::distance).collect(Collectors.toList())); | |
} |
This file contains 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
//Sane signature: Acc -> (Acc, [(Int, Int)]) the list of pair returned contains the index and the amount of votes associated | |
public static Function<HoughAccInterface, Pair<HoughAccInterface, List<Pair<Integer, Integer>>>> mapToClusters(int minVotes, int neighborhood) { | |
return hough -> { | |
//Sane: [(Int, Int)] -> (Int, Int) -> [(Int, Int)] | |
BiFunction<List<Pair<Integer, Integer>>, Pair<Integer, Integer>, List<Pair<Integer, Integer>>> accumulator = (acc, pair) -> { | |
int votes = pair._1(); | |
int index = pair._2(); | |
Pair<Integer, Integer> coord = hough.convertIndex(index); | |
if (votes > minVotes && isLocalMaxima(hough, coord._1(), coord._2(), neighborhood)) { | |
acc.add(new Pair<>(index, votes)); |
This file contains 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
\documentclass{article} | |
\usepackage{tikz} | |
\usepackage{pgfplots} | |
\begin{document} | |
\begin{tikzpicture} | |
\begin{axis}[nodes near coords, | |
ytick=data, | |
xtick=data, |
This file contains 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
//You can put those functions in an external file. Call it for example "Utilities.swift" | |
//Random number between ranges | |
func random(min min: Int, max: Int) -> Int { | |
return Int(arc4random_uniform(UInt32(max - min))) + min | |
} | |
func random(range: Range<Int>) -> Int { | |
return random(min: range.startIndex, max: range.endIndex) | |
} |
NewerOlder