Skip to content

Instantly share code, notes, and snippets.

needs struct'
with struct'
: clone' ( a-a ) here 2dup swap size dup push allot pop copy ;
{ 2 fields .name .personal-dict } user
: ;parse ( "-$ ) '; accept tib keepString ;
: name: ( a"- ) ;parse swap .name ! ;
user luke
luke name: Luke Parrish;
needs decimal'
with decimal'
: sqr ( n-n ) dup * ;
3 elements i j sum
1 !i 1 !j 0 !sum
8 !scale
: // ( nn-n ) push 100000000 * pop / ;
: pi_series ( -) repeat @j @i // @sum + !sum 4 @sum * yield @i 2 + !i @j -1 * !j again ;
3 elements s0 s1 s2
@lsparrish
lsparrish / gist:3808899
Created October 1, 2012 01:03
Generator in Retro
( generator )
{{
: xt, ( - ) 1 , @last @d->xt , ;
---reveal---
: yield ( - ) 1 , here 5 + , xt, [ :is ] , 9 , xt, [ :devector ] , ;
compile-only
}}
: foo ( - ) "State one" puts yield
"State two" puts ;
@lsparrish
lsparrish / iotest.hs
Created September 27, 2012 00:53
IO Test
import IO
-- IO playground
intro :: String
intro = "Hello, welcome to the playground."
prompt = "\n->"
--
quit :: IO ()
quit = do putStr "\nGoodbye."
loop :: IO ()
Idea: Digital commodity that acts as a source of credit and currency exchange.
Bitcoin already provides a good way of creating a chain of digital transactions that can't easily be faked. This kind of transaction could be tied to something more elaborate. Among the possibilities, a distributed system for generating currency in a manner that is similar to a loan against collateral.
1. Alice generates a hard hashes against genesis block containing her public key.
2. Bob (and everyone) verifies that they are indeed hard and against the genesis block.
3. Alice sends Claire a transaction signed with her public key.
4. Bob verifies that the transaction is signed by someone with Alice's (i.e. the hard hash solver's) public key.
So far, I'm describing bitcoin. However additional rules can be added to enable conversions like this:
@lsparrish
lsparrish / gist:2934446
Created June 15, 2012 02:52
Convert retro-language bzr repo to git repo and push to github
mkdir ~/bzr
cd ~/bzr
bzr branch lp:retro-language
mkdir ~/github
mkdir ~/github/retro-language
cd ~/github/retro-language
git init
bzr fast-export --plain ~/bzr/retro-language/ | git fast-import
git checkout master
git remote add origin https://github.com/lsparrish/retro-language.git
Idea: Liquid nitrojen jet cutter for CNC
This would be a novel form of CNC. Instead of waterjet, use liquid nitrogen.
A small high-tensile canister full of LN2 would be equipped with a small nozzle at the bottom, which would eject a high-speed burst of liquid nitrogen. Pressure would come from gas build-up in the top from boiling.
@lsparrish
lsparrish / bitzap.py
Last active November 4, 2015 06:13
simple bitoin-like program
#==========Bitzap: a tiny bitcoin-like program.==========#
# The goal is secure published transactions. Not yet completed.
# Install Notes:
# Uses dbdict, a recipe from: http://code.activestate.com/recipes/576642-persistent-dict-with-multiple-standard-file-format/
# On Ubuntu the Crypto library can be installed with "sudo apt-get install python-crypto"
# Details:
# Addresses are first 32 chars of a hash of the public key.
# Transaction IDs are first 32 chars of the buyer's signature.
# Receipts are lists of debits and credits that have been applied to each address.
# Buyer is sender, seller is receiver.
chain: struct'
: { ( -n ) 0 ;
: field ( nn"-n ) over ` : .data ` + ` ; + ;
: } ( n"- ) ` : .data ` here ` swap ` allot ` constant ` ; ;
: clone ( a-a ) here swap 3 + @ allot ;
;chain
with struct'
{
2 field .bar
1 field .baz
chain triggers'
{{
variable dict
: m dup 0 =if nip 0 ;then 2dup 1+ @ =if nip 2 + 0 ;then ;
: n here dict @ , dict ! , ;
: ? dict repeat @ m 0; again ;
---reveal---
: __? @ ? 0; .word ; parsing
: > compiler off 9 , key dup emit n 8 , , ; compile-only
: < here compiler on ;