This file contains 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
#include "Cmm.h" | |
#define W_TO_SHORT(x) %lobits32(x) | |
crc16u { | |
/* R1 uint32_t input, | |
R2 uint16_t data, | |
R3 Int size */ | |
I32 c; |
This file contains 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
import Criterion.Main | |
import System.Environment | |
import qualified Data.Vector.Unboxed as V | |
magicHere :: Int -> Int | |
magicHere n = V.sum (V.take n p1) | |
where | |
p1 = V.unfoldr (\(c,s) -> let k = c+s in k `seq` Just (k,(c+1,k))) (0,1) |
This file contains 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
import Criterion.Main | |
import System.Environment | |
import qualified Data.Vector.Unboxed as V | |
magicHere :: Int -> Int | |
magicHere n = V.sum (V.take n p1) | |
where | |
p1 = V.unfoldr (\(c,s) -> let k = c+s in k `seq` Just (k,(c+1,k))) (0,1) |
This file contains 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
У меня возникла следующая задача, не по работе, | |
а обучения ради, в результате которой возник | |
вопрос, а как правильно писать tying the knot | |
алгоритмы. (Сама задача решена, теперь остаётся вопрос как это сделать красиво) | |
Задача: | |
Полная задача это подсчёт очков в го, но она | |
разбита на подзадачи. | |
Текущая задача: Дана сетка в R^n, в узлах сетки или | |
стенка или пустое место, нужно на каждом пустом |
This file contains 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
{-# LANGUAGE Rank2Types #-} | |
import Data.Function | |
import Control.Monad | |
data M m a = M a | |
instance Monad (M m) where | |
return = M | |
(M a) >>= f = f a |
This file contains 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
type IsoKey = Int | |
-- | Serialized element | |
data ElementS = ElementS Int [IsoKey] | |
data Element = Element Int [Isotope] deriving (Show) | |
data Isotope = Isotope IsoKey Element deriving (Show) -- payload | |
to :: [ElementS] -> [Element] | |
to es = let result = map (\(ElementS z keys) -> Element z (map (\k -> Isotope k (un help k)) keys)) es | |
help = zip es result |
This file contains 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
main = withSocketsDo $ | |
eventChan <- newChan | |
tm <- newTimerIO | |
forever $ | |
bracket (createNetwork tm chan) | |
(threadKill) $ waitTimer tm >> resetTimer tm | |
where | |
createNet tm chan = bracket (connect) (sClose) (network tm chan) | |
connect = do | |
addrinfos <- getAddrInfo Nothing (Just "") (Just "3000") |
This file contains 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
import Control.Monad.State (StateT) | |
import qualified Control.Monad.State as State | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import Data.IORef (IORef) | |
import qualified Data.IORef as IORef | |
data AbstractKVS m k v = AbstractKVS | |
{ kvsPut :: k -> v -> m () | |
, kvsGet :: k -> m (Maybe v) |
This file contains 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
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} |
This file contains 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
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE Rank2Types #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} |