This file contains hidden or 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
-- roll.hs a dice rolling shell utility | |
-- David Castellà 'kaste' <[email protected]> | |
import Data.List.Split | |
import Data.List | |
import Data.Char | |
import System.Random | |
import Control.Monad | |
import Control.Arrow | |
import Options.Applicative |
This file contains hidden or 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 ExampleReader where | |
import Control.Monad.Reader | |
data Person = Pr { name :: String, | |
age :: Integer, | |
address :: String } | |
type PersonReader = Reader Person String | |
This file contains hidden or 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 BinTree where | |
data BinTree a = Leaf | |
| Node (BinTree a) a (BinTree a) | |
instance Show a => Show (Tree a) where | |
show Leaf = "Leaf" | |
show (Node lt x rt) = "(" ++ show lt ++ " " ++ show x ++ " " ++ show rt ++ ")" | |
-- Tree is a Functor |
This file contains hidden or 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
; Classic recursion | |
(defn fibo [n] | |
(if (or (= n 0) (= n 1)) | |
n | |
(+ (fibo (dec n)) (fibo (- n 2))))) | |
(map fibo (range 15)) | |
; Tail-call recursion | |
(defn fibo2 [n] |
This file contains hidden or 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 <SerialGraphicLCD.h>//inculde the Serial Graphic LCD library | |
#include <SoftwareSerial.h> | |
#include <SPI.h> | |
#include <Ethernet.h> | |
byte mac[] = { | |
0x90, 0xA2, 0xDA, 0x00, 0x7F, 0xC2 }; | |
IPAddress ip(192,168,1,177); |
This file contains hidden or 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
/* | |
* Author: David Castellà <d.castella.85 at gmail dot com> | |
* Sketch title: Bluetooth temperature monitor | |
* Sketch filename: btmon.ino | |
* Date: 2014/05/21 | |
* Version: 0.1 | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or |
This file contains hidden or 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
(defn rpswinner | |
[match] | |
(if (= ((match 0) 1) ((match 1) 1)) | |
(match 0) | |
(if (and (= ((match 0) 1) "R") (= ((match 1) 1) "P")) | |
(match 1) | |
(if (and (= ((match 0) 1) "P") (= ((match 1) 1) "S")) | |
(match 1) | |
(if (and (= ((match 0) 1) "S") (= ((match 1) 1) "R")) | |
(match 1) |