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
15:59 < ocharles> klrr_: that's euler integration | |
15:59 < ocharles> klrr_: the idea is that we assume the thing being integrated is a stepped graph | |
15:59 < ocharles> so we take the last produced value and multiple it by dt - which means we assume | |
that for dt seconds the value was the previous value | |
16:00 < ocharles> then we add that onto an accumulator | |
16:00 < ocharles> so we're approximing an integral by sampling at some frequency and assuming a | |
'rectangle' under the curve until the next instant |
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
14:23 < Cale> klrr_: I'm not sure why there isn't a constB |
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
import Control.Monad (when) | |
import qualified Graphics.UI.SDL as SDL | |
import qualified Graphics.UI.SDL.Image as Image | |
data Mouse = LeftButton | MiddleButton | RightButton | |
position :: IO (Int, Int) | |
position = SDL.getMouseState >>= \(x, y, _) -> return (x, y) | |
isDown :: Mouse -> IO Bool |
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 Tob.Config where | |
import Data.ConfigFile (readstring, emptyCP, get) | |
import Tob.Types | |
getConfig :: FilePath -> IO Config | |
getConfig f = do | |
s <- readFile f | |
let config = do | |
c <- readstring emptyCP s |
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
import Text.ParserCombinators.Parsec | |
data Prefix = Prefix String String String deriving Show | |
data Command = Action String | Code Int deriving Show | |
data Params = Params [String] deriving Show | |
data Message = Message (Maybe Prefix) Command Params String deriving Show |
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
import Text.ParserCombinators.Parsec | |
data Prefix = Prefix String String String deriving Show | |
data Command = Action String | Code Int deriving Show | |
data Params = Params [String] deriving Show | |
data Message = Message (Maybe Prefix) Command Params String deriving Show |
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
import Control.Monad.State (State, get, put, runState) | |
inc :: State Int () | |
inc = fmap (+ 1) get >>= put | |
-- get returns the state's int | |
-- fmap applies (+ 1) on that int | |
-- >>= applies the result to put which makes it the current state | |
reset :: State Int () | |
reset = put 0 |
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
(ns tob.core | |
(:import (java.net Socket) | |
(java.io PrintWriter InputStreamReader BufferedReader))) | |
(def codetalk {:name "irc.codetalk.io" :port 6667}) | |
(def user {:name "tob" :nick "tob"}) | |
(declare conn-handler) | |
(defn connect [server] |
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
(ns tob.irc | |
(:import (java.net Socket) | |
(java.io PrintWriter InputStreamReader BufferedReader))) | |
(def codetalk {:name "irc.codetalk.io" :port 6667}) | |
(def user {:name "tob the bot" :nick "tob"}) | |
(declare conn-handler) | |
(defn connect [server] |
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
(ns tob.core | |
(:require [tob.irc])) | |
(def irc (connect codetalk)) | |
(defn -main [& args] | |
(do | |
(login irc user) | |
(write irc "JOIN #lobby") | |
(write irc "PRIVMSG #lobby : hai! im a lisp irc bot") |