Skip to content

Instantly share code, notes, and snippets.

@geoffrasb
geoffrasb / frp_note.txt
Last active September 4, 2015 10:07
FRP learning note
reference: Functional Reactive Animation - by Conal Elliott et al
* 2 things:
- Behavior a
- Event a
* semantic functions
- at :: Behavior a -> Time -> a
- occ :: Event a -> (Time, a)
@geoffrasb
geoffrasb / Parser.js
Last active August 29, 2015 13:57
[JS] FP facilities and Parser Combinator
window.Parser = {
/* need to add mutual-recursive parser combinator
components:
reg
eof
ret
opt
seq
tryp
@geoffrasb
geoffrasb / data.c
Last active December 27, 2015 20:39
little typing sys
/*
for each type:
1. Define in Type as "newtype_t".
2. Define constructors.
If struct is needed, name it "Newtype_t".
3. Define "_deNewtype", which typed as "Data -> void".
*/
#include<assert.h>
@geoffrasb
geoffrasb / gist:4075271
Created November 14, 2012 22:21
matlab: matrix construction
expand(vec,dims)
# split vec into layers
ex:expand([1;2],[]) -> [1;2]
expand([1;2],[2]) -> [1 2;
1 2]
expand([1;2],[2 3]) ->
1 1 1 2 2 2
1 1 1 2 2 2 (a 2*3*2 matrix)
expand([1;2;3],[1 2]) ->
1 1 2 2 3 3 (a 1*2*3 matrix)
@geoffrasb
geoffrasb / gist:3049840
Created July 4, 2012 22:30
emacs notes
C-v ->vim:c-d
m-v ->vim:c-u
c-l ->vim:z.
c-u 0 c-l
m-f ->vim:w
c-a ->vim:0
c-e ->vim:$
m-a ->vim:{
m-e ->vim:}
m-< ->vim:gg
@geoffrasb
geoffrasb / console.v
Created June 13, 2012 12:09
brainfuck implementation in verilog
module Console_module (
input reset,
output [7:0] LCD_DATA,
output LCD_ENABLE,
output LCD_RW,
output LCD_RSTN,
output LCD_CS1,
output LCD_CS2,
output LCD_DI,
input lcd_clock,
(setf smdl
(quote
;-----------write SMDL here and command (compile-it "filename")----------------------------
;this is and example
(state-machine
(clock "clk")
(init-state A)
(triggerd
("tri"
"n_sig1" "n_sig2"))
@geoffrasb
geoffrasb / gist:2828184
Created May 29, 2012 12:40
eval and macro
>(defmacro add-to-list (a lst)
`(setf ,lst (cons ,a ,lst)))
>(setf lst '(1 2)) ; lst是一個變數,值為(1 2)這個list
>(setf a 'lst) ; a是一個變數,值為#:LST這個symbol
>(cons 3 lst) ;lst先被evaluate
(3 1 2)
>lst
(1 2) ;lst的值不會變
aaaaa
bbb
@geoffrasb
geoffrasb / mylib.lsp
Created May 5, 2012 09:33
my lisp lib
;longer,filter,group (p47
;flatten,prune (p49
;find2,before,after,duplicate,split-if (p50
;most,best,mostn (p52
;map0-n,map1-n,mapa-b,map->,mappend,mapcars,rmapcar (p54
;readlist,prompt,break-loop (p56
;mkstr,symb,reread,explode (p58
;memoize (p65
;rfind-if (p73