#lit - a modern literate programming tool
Lit has several notable features:
- All prose can expressed in Markdown or plaintext
- Supports all programming languages in theory
- Literate constructs defined by indentation
- Watch literate files for changes
# the midpoint approximation of the integral of x*x from [0 1], with 10 subdivisions | |
# integral.midpoint(lambda x: x*x,0,1,10) | |
def trapezoidal(f, start, end, n, _area=0, _n=0): | |
if _n is 0: | |
return trapezoidal(f, start, end, n, _area, n) | |
elif n is 0: | |
return _area | |
else: | |
delta_x = (end - start) / (_n * 1.0) |
function Map() { | |
var dict = {}; | |
return { | |
add_key_value_pair: function(key, value) { | |
dict[key] = value; | |
}, | |
get_value: function(key) { | |
var val = dict[key]; | |
if (val === undefined) { |
choose :: [a] -> Int -> [[a]] | |
choose _ 0 = [[]] | |
choose [] k = [] | |
choose (x:xs) k = thoseWith ++ thoseWithout | |
where | |
thoseWith = map (x :) (choose xs (k - 1)) | |
thoseWithout = choose xs k |
come get give go keep let make put seem take be do have say see send may will about across after against among at before between by down from in off on over through to under up with as for of till than a the all any every little much no other some such that this I he you who and because but or if though while how when where why again ever far forward here near now out still then there together well almost enough even not only quite so very tomorrow yesterday north south east west please yes account act addition adjustment advertisement agreement air amount amusement animal answer apparatus approval argument art attack attempt attention attraction authority back balance base behavior belief birth bit bite blood blow body brass bread breath brother building burn burst business butter canvas care cause chalk chance change cloth coal color comfort committee company comparison competition condition connection control cook copper copy cork cotton cough country cover crack credit crime crush cry current curve dama |
" Make switching buffers easy | |
nmap <Leader>b :ls<CR>:buffer!<Space> | |
imap \ <Esc> | |
vmap \ <Esc> | |
inoremap <C-\> \ | |
nnoremap \ :noh<CR> | |
map <down> <C-d>zz | |
map <up> <C-u>zz | |
nnoremap <tab> zz |
,---, ___ ___ | |
,--.' | ,-.----. ,--.'|_ ,--.'|_ | |
| | : \ / \ __ ,-. ,---,. | | :,' | | :,' | |
: : : | : | ,' ,'/ /| ,' .' | .--.--. : : ' : : : ' : .--.--. | |
: | |,--. .--, | | .\ : ,---. ' | |' |,---.' ,/ / '.;__,' / ,--.--. .;__,' / / / ' | |
| : ' | /_ ./| . : |: | / \ | | ,'| | | : /`./| | | / \ | | | | : /`./ | |
| | /' :, ' , ' : | | \ : / / |' : / : : .'| : ;_ :__,'| : .--. .-. |:__,'| : | : ;_ | |
' : | | /___/ \: | | : . |. ' / || | ' : |.' \ \ `. ' : |__ \__\/: . . ' |
#!/usr/local/bin/gawk -f | |
BEGIN { | |
for (i in ARGV) { | |
if (ARGV[i] == "--sep") { | |
sep = ARGV[i + 1]; | |
"echo \'" sep "\'" | getline sep | |
} | |
ARGV[i] = ""; | |
} |
# Big ideas | |
# | |
# - 2 types of shell tools | |
# - Compute (ls, rm, find, grep, vim ..) | |
# - Format (sort, tail, cut, uniq, sed, ..) | |
# - awk is the ultimate formatting tool | |
# - a complete prog lang for text processing | |
# - handle state on the cmd line | |
# - 2 major datatypes |