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 TemplateHaskell, DeriveDataTypeable, DeriveGeneric #-} | |
import Control.Monad | |
import Data.Binary | |
import Data.Typeable | |
import GHC.Generics | |
import Text.Printf | |
import Control.Distributed.Process | |
import Control.Distributed.Process.Closure | |
import Control.Distributed.Process.Node |
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
-module(plustest). | |
-compile(export_all). | |
plus1(A, B) -> A + B. | |
plus2(A, B) -> erlang:'+'(A, B). | |
plus3(A, B) -> | |
F = fun erlang:'+'/2, | |
apply(F, [A, B]). |
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
-module(niftest). | |
-export([add/2]). | |
-on_load(init/0). | |
init() -> | |
ok = erlang:load_nif("./nif", 0). | |
add(_, _) -> | |
exit(nif_library_not_loaded). |
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
data Event = Event Int | EventTree Int Event Event deriving(Eq, Show) | |
data Id = IdLo | IdHi | Id Id Id deriving(Eq, Show) | |
data Stamp = Stamp Id Event deriving(Eq, Show) | |
instance Ord Event where | |
(<=) (EventTree n1 l1 r1) (EventTree n2 l2 r2) = n1 <= n2 && ((lift (Event n1) l1) <= (lift (Event n2) l2)) && ((lift (Event n1) r1) <= (lift (Event n2) r2)) | |
(<=) (EventTree n1 l1 r1) (Event n2) = n1 <= n2 && ((lift (Event n1) l1) <= (Event n2)) && ((lift (Event n1) r1) <= (Event n2)) | |
(<=) (Event n1) (EventTree n2 _ _) = n1 <= n2 |
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
-module(luhn). | |
-export([check/1]). | |
-spec check([integer()]) -> boolean(). | |
check(Number) -> | |
{Check, _} = lists:foldr( | |
fun | |
(N, {A, odd}) -> |
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
package main | |
import ( | |
"fmt" | |
"os" | |
"unsafe" | |
"syscall" | |
) | |