Skip to content

Instantly share code, notes, and snippets.

clojj clojj

Block or report user

Report or block clojj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@clojj
clojj / Lib.hs
Last active Oct 18, 2019
Haskell literal Html
View Lib.hs
{-# LANGUAGE OverloadedStrings #-}
module Lib
( Html, Markup(..), html, eval
) where
eval :: Html -> String
eval (Html head body) = "<html>" ++ evalHead head ++ evalBody body ++ "</html>"
evalHead :: Head -> String
@clojj
clojj / lazylist.u
Last active Sep 19, 2019
Lazy lists for Unison
View lazylist.u
use .builtin
use .builtin.Nat
use .builtin.Int
use .builtin.List
use .builtin.Optional
-- TODO use Fix type
type Fix f = Fix (f (Fix f))
type LazyList a = LazyNil | LazyCons a (() -> LazyList a)
View docker_commands.md

enter a container's shell

docker ps -> ID

docker exec -it 42 bash

copy a file to container

View Tictactoe.hs
data Coord = One | Two | Three deriving (Enum, Eq)
data Symb = O | X | Nada deriving (Show, Eq)
type TicTacToe = Coord -> Coord -> Symb
showBoard :: TicTacToe -> String
showBoard b = unlines $ map showLine [One .. Three]
where
showLine c = unwords $ map (showHouse $ b c) [One .. Three]
showHouse b' c = show $ b' c
View ListComprehensions.hs
permutations :: (Eq a) => [a] -> [[a]]
permutations [] = [[]]
permutations l = [a:x | a <- l, x <- (permutate $ filter (\x -> x /= a) l)]
allUnique :: Eq a => [a] -> Bool
allUnique [] = True
allUnique ls = and [r | x <- ls, r <- [length (filter (\e -> e /= x) ls) == (length ls) - 1]]
View Factorial.hs
{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-}
#include <factorial.h>
#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
module Factorial (factorial) where
import Control.Monad
import Foreign.Ptr
import Foreign.ForeignPtr
View factorial.c
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <factorial.h>
/* Calculates max and allocate table. Returns !0 if
* memory could not be allocated.
*/
int factorial_table_init(factorial_table *t)
View factorial.h
/* A table of factorials. table[i] is the factorial of i. The
* max field is calculated so that its factorial would not be an
* integer overflow.
*/
typedef struct {
unsigned max;
unsigned *table;
} factorial_table;
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)
}}
You can’t perform that action at this time.