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
let | |
val Id = fn x => x | |
in | |
Id | |
end | |
(* | |
Warning: type vars not generalized because of | |
value restriction are instantiated to dummy types (X1,X2,...) |
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
-- Solution to http://beust.com/weblog/2011/10/30/a-new-coding-challenge/ | |
import Data.List(isInfixOf) | |
partitions n 1 = [[n]] | |
partitions n k | n > 0 = [m:ms | m <- [1..n `div` 2], ms <- partitions (n-m) (k-1)] | |
partitions n k | otherwise = [] | |
weighings [] = [0] | |
weighings (w:ws) = [m + n | m <- weighings ws, n <- [-w, 0, w]] |
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
(usefd) | |
(define (powerset a) | |
(if (null? a) (list '()) | |
(let ((p (powerset (cdr a)))) | |
(append (map (lambda (x) (cons (car a) x)) p) p)))) | |
(define (remove-duplicates l) | |
(do ((a '() (if (member (car l) a) a (cons (car l) a))) | |
(l l (cdr l))) |
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
{-# OPTIONS --universe-polymorphism #-} | |
module match where | |
open import Data.List hiding (or) | |
open import Category.Monad | |
open import Category.Functor | |
open import Function | |
open import Data.Maybe | |
open import Data.Bool | |
open import Data.Nat | |
open import Relation.Binary.PropositionalEquality |
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
<!-- | |
I'm sure there's a better syntax for naming subtemplates | |
--> | |
<h3>This is a list</h3> | |
<ul> | |
{{#each items}} | |
{{@cell}} | |
<li> | |
{{..}} |
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
(ns match.pojo | |
(:use [match.core :only [IMatchLookup val-at* match]])) | |
(set! *warn-on-reflection* true) | |
(defmacro pojo-match | |
"Generate an implementation of match.core/IMatchLookup for the given Java class. | |
Keys are mapped like this: | |
isVisible -> :visible? |
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
/* | |
* Nonogram/paint-by-numbers solver in SWI-Prolog. Uses CLP(FD), | |
* in particular the automaton/3 (finite-state/RE) constraint. | |
* Copyright 2011, 2014 Lars Buitinck | |
* Copyright 2014 Markus Triska | |
* Do with this code as you like, but don't remove the copyright notice. | |
*/ | |
:- use_module(library(clpfd)). |
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
(deftyped | |
addInteger | |
[Integer :> [Integer :> Integer]] | |
[x y] | |
(+ x y)) | |
(deftyped | |
addDouble | |
[Double :> [Double :> Double]] |
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
package demo | |
class Coder(words: List[String]) { | |
private val mnemonics = Map( | |
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL", | |
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ") | |
private val charCode: Map[Char, Char] = | |
for ((digit, str) <- mnemonics; letter <- str) yield letter -> digit |
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
(ns clojure.core.logic.assoco | |
(:refer-clojure :exclude [== reify inc not]) | |
(:use [clojure.core.logic minikanren prelude match disequality])) | |
;; defining assoc as a pure relation | |
;; a good example of the non-overlapping | |
;; clauses property. A given map can match | |
;; only one of the these clauses. | |
(defne assoco [m k v o] |