Skip to content

Instantly share code, notes, and snippets.

View dktn's full-sized avatar

Adam Szlachta dktn

  • Restaumatic
  • Kraków
View GitHub Profile
{
"workbench.colorTheme": "DktnBrain",
"terminal.integrated.fontSize": 12,
"window.zoomLevel": 0,
"window.restoreWindows": "all",
"editor.fontSize": 12,
"editor.lineHeight": 15,
@dktn
dktn / Solver1.hs
Created March 14, 2019 00:53
Brute force solver 1
module Solver1 where
import Data.Ord (comparing)
import Data.Foldable (minimumBy)
maxVal :: [(Int, Int)] -> Int
maxVal l = max (maximum l1) (maximum l2)
where
(l1, l2) = unzip l
@dktn
dktn / Main.elm
Created October 15, 2019 22:41
Elm example program
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Browser exposing (sandbox)
type alias Model =
{ message : String
, count : Int
}
@dktn
dktn / BSF.hs
Created December 31, 2019 13:24
module BSF where
import Universum
import Data.Sequence (Seq (..), (><))
import qualified Data.Sequence as Seq
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
@dktn
dktn / bsf.py
Last active December 31, 2019 13:33
# from a book Grokking Algorithms
from collections import deque
graph = {}
graph["you"] = ["alice", "bob", "claire"]
graph["bob"] = ["anuj", "peggy"]
graph["alice"] = ["peggy"]
graph["claire"] = ["thom", "johny"]
graph["anuj"] = []
(ns bsf)
(defn queue
([] (clojure.lang.PersistentQueue/EMPTY))
([coll]
(reduce conj clojure.lang.PersistentQueue/EMPTY coll)))
(def graph1
{"you" '("alice" "bob" "claire")
"bob" '("anuj" "peggy")
-- specular
-- Specular.FRP.Base
nextTimeRef :: Ref Time
readBehavior :: forall a. Behavior a -> Pull a
newtype Event a = Event
{ occurence :: Behavior (Maybe a)
, subscribe :: Listener -> Effect Unsubscribe
}
newtype Dynamic a = Dynamic
-- -------------------------- specular --------------------------
-- Specular.FRP.Base
filterMapEvent :: forall a b. (a -> Maybe b) -> Event a -> Event b
filterEvent :: forall a. (a -> Boolean) -> Event a -> Event a
filterJustEvent :: forall a. Event (Maybe a) -> Event a
subscribeEvent_ :: forall m a. MonadEffect m => MonadCleanup m => (a -> Effect Unit) -> Event a -> m Unit
never :: forall a. Event a
newEvent :: forall m a. MonadEffect m => m { event :: Event a, fire :: a -> Effect Unit }
leftmost :: forall a. Array (Event a) -> Event a