docker ps -> ID
docker exec -it 42 bash
| data class Property(val name: String, val objectRef: String? = null) | |
| data class Model(val name: String, val properties: List<Property>) | |
| val m1 = Model( | |
| "m1", listOf( | |
| Property("p11"), | |
| Property("p12", "m2"), | |
| ) |
| import kotlinx.coroutines.async | |
| import kotlinx.coroutines.runBlocking | |
| import kotlinx.coroutines.coroutineScope | |
| import kotlinx.coroutines.awaitAll | |
| suspend fun <A, B> Iterable<A>.pmap(f: suspend (A) -> B): List<B> = coroutineScope { | |
| map { async { f(it) } }.awaitAll() | |
| } |
| {-# 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 |
| 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) |
| 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 |
| 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]] |
| {-# 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 |
| #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) |
| /* 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; |