PurposeThis provides a place for code fragments I find interesting. |
A placeholder for now (December 3, 2012)
#! /bin/sh e(){ echo -n $1 ;};s(){ e S; e m;e i;e l;e e;e '!';}; cd(){ if [ -n "$1" ];then l="$1";shift;s;cd "$@" ; else echo "";fi;} d0(){ if [ -n "$1" ];then cd "$@";shift;d0 "$@";fi;} d0 your own homework
#include <unistd.h> #define T C Z #define X Z V #define R char #define V void #define C const #define U return #define Z static #define do d T R S[] = { 's', 'm', 'i', 'l', 'e', '\0' }; X w(R c) {write(1,&c,1);} X n(V) {w('\n');} X W(R c) {c -= 'a';c+= 'A';w(c);} X e(C R *s) { W(*s); for(s++;*s;s++) w(*s); w('!');} X f(R **s) {if(!*s){n();U;}e(S);f(s+1);} X do(R **s) {if(!*s)U;f(s);do(s+1);} int main(argc,argv) int argc; char *argv[]; { char *what[] = {"do", "uour own", "homework", (char *) NULL }; do(what); return (0); }
#! /bin/sh e(){ echo -n $1 ;};s(){ pop '!' e l i m S;}; pop(){ local l;[ -z "$1" ] && return;l="$1";shift;pop $*;e "$l";}; cd(){ if [ -n "$1" ];then l="$1";shift;s;cd "$@";else echo "";fi;} d0(){ [ -z "$1" ] && return;cd "$@";shift;d0 "$@";} d0 your own homework
#include <unistd.h> #define Q(q,p) N(q,p,c) #define Y(q,p) X q(R **s){if(!*s)p;q(s+1);} #define O(q,p,o) N(q,p,*o) #define N(q,p,o) X q(R o){p;} #define X Z V #define R char #define V void #define C const #define U return #define Z static #define do d #define n w('\n') Z R S[]={'e','l','i','m','s','\0'}; Q(w,write(1,&c,1))Q(W,c-='a';c+='A';w(c)) O(g,if(!*(s+1)){W(*s);U;};g(s+1);w(*s),s) O(e,g(s);w('!'),s)Y(f,{n;U;}e(S))Y(do,U;f(s)) int main(argc,argv) int argc; char *argv[]; { char *what[] = {"do", "uour own", "homewerk", (char *) NULL }; do(what); return (0); }