Skip to content

Instantly share code, notes, and snippets.

View FindByTitleKotlin.kt
var findByTitle: (String) -> (MutableList<Movie>) -> List<Movie> =
{ query -> { collection ->
val predicate = matches(query)
filter(predicate)(collection)
}}
val filter: ((Movie) -> Boolean) -> (List<Movie>) -> List<Movie> =
{ predicate -> { collection ->
collection.filter(predicate)
}}
View FindByTitleKotlin.kt
var findByTitle: (String) -> (MutableList<Movie>) -> List<Movie> =
{ query -> { collection ->
val predicate = matches(query)
filter(predicate)(collection)
}}
val filter: ((Movie) -> Boolean) -> (List<Movie>) -> List<Movie> =
{ predicate -> { collection ->
collection.filter(predicate)
}}
@clojj
clojj / main.hs
Created Oct 12, 2018
InsistentLazyRedundantcode created by anonymous - https://repl.it/repls/InsistentLazyRedundantcode
View main.hs
gcdHaskell :: Int -> Int -> Int
gcdHaskell x y | x > y = gcdHaskell (x - y) y
| x < y = gcdHaskell x (y - x)
| otherwise = x
main = print $ gcdHaskell 4 2
@clojj
clojj / ttt.idr
Created Oct 13, 2017
fresh start on typed tic tac toe
View ttt.idr
module TicTacToe
import Data.Vect
data Piece = X | O | N
next : Piece -> Piece
next X = O
next O = X
next N = N
@clojj
clojj / tictactoe.idr
Last active Oct 12, 2017
Idris type-level tic-tac-toe
View tictactoe.idr
module TicTacToe
import Data.Vect
||| All possible player pieces, where N represents empty
data Piece = X | O | N
||| Select next player
next : Piece -> Piece
next X = O
View tictactoe.idr
module TicTacToe
import Data.Vect
||| All possible player pieces, where N represents empty
data Piece = X | O | N
||| Select next player
next : Piece -> Piece
next X = O
@clojj
clojj / compose.hs
Last active Jan 26, 2017
compose function from list of functions
View compose.hs
import Data.List
compose :: [a -> a] -> a -> a
compose fs v = foldl' (flip (.)) id fs $ v
@clojj
clojj / compose-maybe-functions.hs
Last active Jan 26, 2017
compose list of Maybe functions
View compose-maybe-functions.hs
import Data.List
compose :: [Maybe (a -> a)] -> a -> a
compose fs v = foldl' compf id fs $ v
compf :: (a -> a) -> Maybe (a -> a) -> (a -> a)
compf f mg =
case mg of
Nothing -> f
Just g -> g . f
@clojj
clojj / Main.hs
Created Jan 21, 2017
mvc with vty
View Main.hs
#!/usr/bin/env stack
-- stack --resolver lts-7.14 --install-ghc runghc --package vty --package pipes --package pipes-concurrency
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Graphics.Vty
import Data.Default
import Control.Monad
import System.IO
@clojj
clojj / InteroProcess.scala
Last active Jan 2, 2017
alternative stdio handling
View InteroProcess.scala
package intellij.haskell.external.repl
import java.io._
import java.util.concurrent.{ConcurrentLinkedDeque, SynchronousQueue}
import com.intellij.util.EnvironmentUtil
import scala.collection.JavaConverters._
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.io._