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
#==========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. |
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
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 |
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
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 ; |
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
chain: stacks' | |
{{ | |
variable this | |
: stack ( -n ) this @ ; | |
---reveal--- | |
: :| ( n- ) this ! ; | |
: |: ( "- ) create here dup :| , 100 allot ; | |
: \ ( n- ) stack ++ stack @ ! ; | |
: / ( -n ) stack @ stack -- @ ; | |
}} |
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
( dict contains link to the most recent char word created. ) | |
( m? is the interrupt detector for the lookup function. ) | |
( l? is the lookup function. returns an xt or 0. ) | |
( : starts a char definition. ) | |
( ; calls a char definition. ) | |
variable dict | |
: m? dup 0 =if nip -1 ( leave 0 on stack after interrupt ) ;then | |
2dup 1+ @ =if nip 2 + -1 ( leave xt on stack after interrupt );then ; | |
: l? dict repeat @ m? if; again ; |
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
#include <stdio.h> | |
char* listen(); | |
int process(); | |
int strcmp(); | |
int output(); | |
int main() { | |
char *str; | |
while (strcmp(str,"bye\n") != 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
chain: stringBuffer' | |
{{ | |
tib variable: buffer | |
@buffer variable: pointer | |
: terminate ( - ) 0 @pointer ! ; | |
: bs? ( c-cf ) dup 8 = ; | |
: remove ( c- ) drop pointer -- @pointer @buffer <if @buffer !pointer then terminate ; | |
: add ( c- ) @pointer ! pointer ++ terminate ; | |
---reveal--- | |
: addToBuffer ( c- ) bs? if remove else add then ; |
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
chain: stringBuffer' | |
{{ | |
tib variable: buffer | |
@buffer variable: pointer | |
: terminate ( - ) 0 @pointer ! ; | |
---reveal--- | |
: addToBuffer ( c- ) @pointer ! pointer ++ terminate ; | |
: getFromBuffer ( -c ) pointer -- @pointer @ terminate ; | |
: endOfBuffer ( -a ) repeat @pointer dup @ 0; 2drop pointer ++ again ; | |
: sizeOfBuffer ( -n ) @pointer @buffer - ; |
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
with quotes' | |
( compare two strings from the beginning and return how many ) | |
( similar characters there are before the strings diverge. ) | |
: ^match ( $$-n ) | |
0 -rot repeat @+ [ swap @+ ] dip =if rot 1+ -rot else 2drop ;then again ; | |
( test each word in the dictionary for similarity. if similar up ) | |
( to the current point, add to the suggestions queue. ) | |
create list here , 100 allot |
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
with strings' | |
with quotes' | |
{ | |
create str0 512 allot | |
create str1 512 allot | |
: NewCompare | |
[ toLower dup getLength 1+ str0 swap copy ] dip | |
toLower dup getLength 1+ str1 swap copy | |
str0 str1 default: compare ; |