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 <stdio.h> | |
#include <stdlib.h> | |
/* | |
* TODO | |
* - Maybe write some macros to facilitate writing the thunks | |
* - Lazy-cons macro? (can't have lazy-cons as a function due to CbV) | |
* - Make sure my memory management strategy isn't shit | |
* - I already know that if you use malloced ptrs in the Generic | |
* it'll fuck shit up |
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
;; Non-tail recursive map | |
(define map | |
(lambda (f ls) | |
(if (null? ls) | |
'() | |
(cons (f (car ls)) (map f (cdr ls)))))) | |
;; > (map add1 '(1 2 3)) | |
;; (2 3 4) |
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
(ns async-tut1.core | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:require [goog.dom :as dom] | |
[goog.events :as events] | |
[cljs.core.async :refer [put! chan <!]] | |
[cljs.core.async :as async])) | |
;; ============================================================================ | |
;; HELPERS |
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 Coord = (Int, Int) | |
type Direction = Coord -> Coord | |
type Boundary = Coord -> Bool | |
north :: Direction | |
north (row, col) = (row - 1, col) | |
south :: Direction | |
south (row, col) = (row + 1, col) |
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 Message = Mark Word8 | Load Word64 Word64 | Undo | Reset | Legal Bool | Suggest Bool | |
newButtonPressEvent :: Int -> m -> Chan m -> IO () | |
newButtonPressEvent pinNumber msg ch = -- forkIO blah blah blah | |
-- Push msg into ch whenever a press occurs on pinNumber (rising edge, basically) | |
-- Usually used partially applied :: Int -> m -> (Chan m -> IO ()) | |
newButtonHoldEvent :: Int -> (Bool -> m) -> Chan m -> IO () | |
newButtonHoldEvent pinNumber msg ch = -- forkIO, recursive loop with lastPressed | |
-- Push msg into ch whenever a hold or release occurs on pinNumber (rising edge = hold, falling edge = releaseS) |
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 Edge = Rising | Falling | |
newGpioEdgeEventHandler :: Int -> (Edge -> Maybe m) -> Chan m -> IO () | |
-- The above function is a more general case of pressing or holding a button | |
-- Holding sends messages on the Rising and Falling edges of a GPIO pin's input | |
-- Pressing only sends messages on a Rising edge | |
-- If you want to not send a message on an edge, just have your | |
-- input function return Nothing | |
-- Otherwise, return Just m |
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
fizzCases = [(3, "Fizz"), (5, "Buzz"), (7, "Baz")] | |
fizzBuzz :: Int -> String | |
fizzBuzz n = case (foldl fizzBuzzify "" fizzCases) of | |
"" -> show n | |
s -> s | |
where | |
fizzBuzzify acc (i, s) = if ((n `mod` i) == 0) then acc ++ s else acc | |
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 = let inputs = [InputAction Immediate $ getGpioRisingEdge ()] | |
initial = cycle "GO PURDUE! " | |
update _ state = tail state | |
outputs = [OutputAction Immediate $ print . head] | |
in topLevel inputs update initial outputs | |
main = let inputs = [InputAction (Repeat 1000000) $ return ()] | |
initial = cycle "GO PURDUE! " | |
update _ state = tail state | |
outputs = [OutputAction Immediate $ print . head] |
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
#!/usr/bin/expect | |
#example state: | |
#-------------------X-------XX------XO--------------------------- O | |
if { $argc != 2 } { | |
puts "USAGE: ./go.exp <BOARD> <PLAYER>" | |
exit 1 | |
} | |
log_user 0 |
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 "p24F08KL302.h" | |
//_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) | |
//_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) | |
_FGS(GSS0_OFF & GWRP_OFF) | |
_FICD(ICS_PGx2) | |
_FWDT(FWDTEN_OFF) | |
_FOSC(FCKSM_CSDCMD & OSCIOFNC_ON & POSCMD_XT) | |
_FOSCSEL(FNOSC_PRI & SOSCSRC_DIG) | |
// generic helpers |
OlderNewer