******************** * * * D E M O F I L E * * * * i R h o v1.1 * * * ******************** This file contains many (non)trivial and tricky examples that can be runned immediately in the interpreter. Hoping you enjoy. For any comment please drop me a message. Luigi.Liquori@inria.fr *** Heating *** 12;; (12 ->13 12);; (12 ->12 14);; 12,13;; 1,2,3;; ((a->b,a->d) a);; *** Small Define Macro (not in the iRho language) *** ID = (X->X);; IDID = (X->X X->X);; ID;; (ID 4);; IDID;; (IDID 4);; *** Sequence macros (not in the language): expr1;expr2 expanded in ((FRESHVAR -> expr2) expr1) *** ID = (X->X);(ID 4);; X->(a;b;c);; *** Matching *** MATCHPAIR = ((f(X,Y)) -> X);(MATCHPAIR (f(2,3)));; MATCHCURRY = (f X Y) -> X;(MATCHCURRY (f 2 3));; **** Non Terminating Programs *** 1) Function with pattern OMEGA = ((fix X) -> (X (fix X)));(OMEGA (fix OMEGA));; 2) Efficient segfault using "=" OMEGA = X -> (OMEGA X);(OMEGA 0);; 3) Classical lambda-term OMEGA = (X -> (X X));(OMEGA OMEGA);; *** Some Peano Numbers Macros *** ZERO = 0;; ONE = (succ 0);; TWO = (succ ONE);; THREE = (succ TWO);; FOUR = (succ THREE);; FIVE = (succ FOUR);; SIX = (succ FIVE);; SEVEN = (succ SIX);; EIGHT = (succ SEVEN);; NINE = (succ EIGHT);; TEN = (succ NINE);; TENONE = (succ TEN);; TENTWO = (succ TENONE);; TENTHREE = (succ TENTWO);; TENFOUR = (succ TENTHREE);; TENFIVE = (succ TENFOUR);; TENSIX = (succ TENFIVE);; TENSEVEN = (succ TENSIX);; TENEIGHT = (succ TENSEVEN);; TENNINE = (succ TENEIGHT);; TWE = (succ TENNINE);; TWEONE = (succ TWE);; TWETWO = (succ TWEONE);; TWETHREE = (succ TWETWO);; TWEFOUR = (succ TWETHREE);; TWEFIVE = (succ TWEFOUR);; TWESIX = (succ TWEFIVE);; TWESEVEN = (succ TWESIX);; TWEEIGHT = (succ TWESEVEN);; TWENINE = (succ TWEEIGHT);; TWETEN = (succ TWENINE);; TRTY = (succ TWETEN);; TRTYONE = (succ TRTY);; TRTYTWO = (succ TRTYONE);; TRTYTHREE= (succ TRTYTWO);; TRTYFOUR = (succ TRTYTHREE);; TRTYFIVE = (succ TRTYFOUR);; TRTYSIX = (succ TRTYFIVE);; TRTYSEVEN= (succ TRTYSIX);; TRTYEIGHT= (succ TRTYSEVEN);; TRTYNINE = (succ TRTYEIGHT);; FRTY = (succ TRTYNINE);; *** Fix point *** FIXV = FUN -> VAL -> (FUN (FIXV FUN) VAL);; *** Functional call-by-value letrec (not in the language), letrec FUN = lambda VAL.|e1| in |e2| expanded in (FUN -> |e2|) (FIXVAL (FUN->VAL->|e1|)) *** 1) fix-pointing an infinite evaluation: letrec FUN = lambda VAL.(FUN VAL) in (FUN 0) LETRECINFTY = ((FUN -> (FUN 0)) (FIXVAL (FUN->VAL->(FUN VAL))));LETRECINFTY;; 2) fix-pointing the plus function: letrec PLUS = lambda (X,Y). matchcase (M,N) (0,N) -> N ((succ M),M) -> (succ (PLUS (M,N))) in (PLUS ((succ (succ 0)),(succ (succ 0)))) LETRECPLUS = ((PLUS -> (PLUS ((succ (succ 0)),(succ (succ 0))))) (FIXVAL (PLUS -> VAL -> (((0,N) -> N , ((succ M),N) -> (succ (PLUS (M,N)))) VAL))));LETRECPLUS;; 3) Simpler and efficient fix-pointing using "=" :this untyped encoding will not typecheck in iRho-2.0 because of lacks of recursive types. PLUS = ((0,N) -> N,((succ N),M) -> (succ (PLUS (N,M))));; (PLUS (THREE,THREE));; 2) This (sugared, i.e. not in the language) encoding use the "[ ...]" macro. This encoding will typechecks in iRho-2.0 thanks to the imperative type features of iRho. The [ ... ] macros will be defined later in the demo, after the introduction of the imperative features. [PLUS = ((0,N) -> N,((succ N),M) -> (succ (PLUS (N,M))))];; (PLUS (THREE,THREE));; *** Control Structures *** 1) Negation NEG = (true -> false, false -> true);; (NEG true);; 2) If-then-else call-by-value...Please, reload OMEGA = (X -> (X X)) IFTHENELSE = (COND,THEN,ELSE) -> ((true -> (X -> THEN dummy) , false -> (Y -> ELSE dummy)) COND);; (IFTHENELSE (true, (Y -> 4),(Y -> (OMEGA OMEGA))));; (IFTHENELSE (false,(Y -> 4),(Y -> (OMEGA OMEGA))));; 3) NEW Simpler way for if then else ELSE <-? COND ?-> THEN 4 <-? true ?-> (X->X 3);; 4 <-? false ?-> (X->X 3);; *** Imperative Features *** ^1,2;; ^(1,2);; (^X -> X ^3);; (!^(X->X) 4);; ((X,Y) -> (X,Y) (^3,^4));; ((X,Y) -> (Y<-!X;(!X,!Y)) (^3,^4));; ((X,Y) -> (Y<-!X;(X,Y)) (^3,^ 4));; ((X,Y) -> (Y<-!X;(X,!X,Y,!Y)) (^3,^4));; ((f X Y) -> (Z -> (X<-!Z) X) (f^3^4));; ( X -> ((^Y -> Y) X) ^4);; *** Segmentation Fault using References *** (X =^dummy;Y=(Z->(!X Z));X<-Y;(Y boommy));; *** Still References *** ONE=((XREF -> ((ONE->XREF<-ONE) 5)) ^dummy);; ONE;; *** Swapping Two Variables *** 1) the AUX var is inside the body SWAP = ((X,Y) -> ((AUX -> (AUX<-!X ; X<-!Y ; Y<-!AUX ; (!X,!Y))) (^0)));; (SWAP (^4 , ^5));; 2) Passing all three variables at once VARSWAP = (X,Y,AUX) -> (AUX<-!X;X<-!Y;Y<-!AUX;(!X,!Y));; (VARSWAP (^4,^5,^0));; 3) Passing all variables a la Curry CURRYSWAP = (X -> Y -> AUX -> (AUX<-!X;X<-!Y;Y<-!AUX;(!X,!Y)));; (CURRYSWAP (^4) (^5) (^0));; *** Negation Normal Form: sharing code *** 1) Some formulas PHI = p;; PHI = (not (not p));; PHI = (not (or (p,p)));; PHI = (not (and (p,q)));; PHI = (and ((and (p,q)),p));; PHI = (and ((not (and (p,q))),(not (and (p,q)))));; [NNF = ( p -> p, q -> q, (not (not X)) -> (NNF X), (not (or (X,Y))) -> (and ((not (NNF X)),(not (NNF Y)))), (not (and (X,Y))) -> (or ((not (NNF X)),(not (NNF Y)))), (and (X,Y)) -> (and ((NNF X),(NNF Y))), (or (X,Y)) -> (or ((NNF X),(NNF Y))))];; (NNF PHI);; *** Exercise: Implement a NNF procedure with sharing code and data (hint: just translate the solution in a recent PPDP-04 paper, see author's web page for a ps/pdf copy) *** ************** * * Peano's Toys * ************** ZERO = 0;; ONE = (succ 0);; TWO = (succ ONE);; THREE = (succ TWO);; FOUR = (succ THREE);; FIVE = (succ FOUR);; SIX = (succ FIVE);; SEVEN = (succ SIX);; EIGHT = (succ SEVEN);; NINE = (succ EIGHT);; TEN = (succ NINE);; TENONE = (succ TEN);; TENTWO = (succ TENONE);; TENTHREE = (succ TENTWO);; TENFOUR = (succ TENTHREE);; TENFIVE = (succ TENFOUR);; TENSIX = (succ TENFIVE);; TENSEVEN = (succ TENSIX);; TENEIGHT = (succ TENSEVEN);; TENNINE = (succ TENEIGHT);; TWE = (succ TENNINE);; TWEONE = (succ TWE);; TWETWO = (succ TWEONE);; TWETHREE = (succ TWETWO);; TWEFOUR = (succ TWETHREE);; TWEFIVE = (succ TWEFOUR);; TWESIX = (succ TWEFIVE);; TWESEVEN = (succ TWESIX);; TWEEIGHT = (succ TWESEVEN);; TWENINE = (succ TWEEIGHT);; TWETEN = (succ TWENINE);; TRTY = (succ TWETEN);; TRTYONE = (succ TRTY);; TRTYTWO = (succ TRTYONE);; TRTYTHREE= (succ TRTYTWO);; TRTYFOUR = (succ TRTYTHREE);; TRTYFIVE = (succ TRTYFOUR);; TRTYSIX = (succ TRTYFIVE);; TRTYSEVEN= (succ TRTYSIX);; TRTYEIGHT= (succ TRTYSEVEN);; TRTYNINE = (succ TRTYEIGHT);; FRTY = (succ TRTYNINE);; *** Factorial *** (don't forget to download the Peano numbers, see above) N.B. mult not implemented [FACT = (0 -> (succ 0) , (succ 0) -> (succ 0) , (succ (succ X)) -> (mult (succ (succ X)) (FACT (succ X))))];; (FACT FIVE);; *** Plus *** [PLUS = ((0,N) -> N , ((succ N),M) -> (succ (PLUS (N,M))))];; (PLUS (FIVE,FIVE));; *** Multiplication (use Plus) *** N.B. note the introduction of "|" as a TRS separator [PLUS = ((0,N) -> N , ((succ N),M) -> (succ (PLUS (N,M)))) | MULT = ((0,M) -> 0, ((succ N),M) -> (PLUS (M,(MULT (N,M)))))];; (MULT (FI,FIVE));; *** Fibonacci (use Plus) *** [PLUS = ((0,N) -> N , ((succ N),M) -> (succ (PLUS (N,M)))) | FIB = (0 -> (succ 0) , (succ 0) -> (succ 0) , (succ (succ X)) -> (PLUS ((FIB (succ X)),(FIB X))))];; (FIB TWETHREE);; *** Power (use Plus and Mult ) *** [PLUS = ((0,N) -> N , ((succ N),M) -> (succ (PLUS (N,M)))) | MULT = ((0,M) -> 0, ((succ N),M) -> (PLUS (M,(MULT (N,M))))) | POW = ((N,0) -> (succ 0), (N,(succ M)) -> (MULT (N,(POW (N,M)))))];; (POW (TWO,TEN));; *** Ackermann *** [ACK = ((0,N) -> (succ N), ((succ M),0) -> (ACK (M,(succ 0))), ((succ M),(succ N)) -> (ACK (M,(ACK ((succ M),N)))))];; (ACK (THREE,FOUR));; ********************* * * Small List Galleria * ********************* ZERO = 0;; ONE = (succ 0);; TWO = (succ ONE);; THREE = (succ TWO);; FOUR = (succ THREE);; FIVE = (succ FOUR);; SIX = (succ FIVE);; SEVEN = (succ SIX);; EIGHT = (succ SEVEN);; NINE = (succ EIGHT);; TEN = (succ NINE);; TENONE = (succ TEN);; TENTWO = (succ TENONE);; TENTHREE = (succ TENTWO);; TENFOUR = (succ TENTHREE);; TENFIVE = (succ TENFOUR);; TENSIX = (succ TENFIVE);; TENSEVEN = (succ TENSIX);; TENEIGHT = (succ TENSEVEN);; TENNINE = (succ TENEIGHT);; TWE = (succ TENNINE);; TWEONE = (succ TWE);; TWETWO = (succ TWEONE);; TWETHREE = (succ TWETWO);; TWEFOUR = (succ TWETHREE);; TWEFIVE = (succ TWEFOUR);; TWESIX = (succ TWEFIVE);; TWESEVEN = (succ TWESIX);; TWEEIGHT = (succ TWESEVEN);; TWENINE = (succ TWEEIGHT);; TWETEN = (succ TWENINE);; TRTY = (succ TWETEN);; TRTYONE = (succ TRTY);; TRTYTWO = (succ TRTYONE);; TRTYTHREE= (succ TRTYTWO);; TRTYFOUR = (succ TRTYTHREE);; TRTYFIVE = (succ TRTYFOUR);; TRTYSIX = (succ TRTYFIVE);; TRTYSEVEN= (succ TRTYSIX);; TRTYEIGHT= (succ TRTYSEVEN);; TRTYNINE = (succ TRTYEIGHT);; FRTY = (succ TRTYNINE);; *** Findn : Find the nth Element in a list *** (don't forget to download the Peano numbers, see above) LIST = (10,11,12,13,15,16,nil);; [FINDN = ((0,nil) -> fail, ((succ N),nil) -> fail, ((succ 0),(X,Y)) -> X, ((succ N),(X,Y)) -> (FINDN (N,Y)))];; (FINDN (THREE,LIST));; *** Killm: Kill in a list the element "m" (if it exist) *** LIST = (n,m,p,q,r,s,t,nil);; [KILLM = ((m,(n,nil)) -> (n,nil), (m,(m,X)) -> X, (m,(n,X)) -> (n,(KILLM (m,X))))];; (KILLM (m,LIST));; *** Some binary operators *** ISZERO = (0 -> true, (succ X) -> false);; PRED = (0 -> 0, (succ X) -> X);; AND = ((true, true) -> true, (true, false) -> false, (false,true) -> false, (false,false) -> false);; OR = ((true, true) -> true, (true, false) -> true, (false,true) -> true, (false,false) -> false);; EQ = ((0,0) -> true, (0,(succ X)) -> false, ((succ X),0) -> false, ((succ X),(succ Y)) -> (EQ (X,Y)));; *** Killany: parametrization of Killm *** LIST = (THREE,FOUR,FIVE,TEN,nil);; [KILL = ((ELM,(nil)) -> (nil), (ELM,(E,X)) -> ((E,(KILL (ELM,(X)))) <-? (EQ (ELM,E)) ?-> (KILL (ELM,(X)))))];; (KILL (FIVE,LIST));; ******************************* * * * Small XML-oriented Galleria * * * ******************************* *** Some list of numbers *** ZERO = 0;; ONE = (succ 0);; TWO = (succ ONE);; THREE = (succ TWO);; FOUR = (succ THREE);; FIVE = (succ FOUR);; SIX = (succ FIVE);; SEVEN = (succ SIX);; EIGHT = (succ SEVEN);; NINE = (succ EIGHT);; TEN = (succ NINE);; *** Some list of friends and the DB *** ME = (person ((first luigi) ,(nat it) ,(cat ONE)));; YOU = (person ((first jessica) ,(nat usa),(cat TWO)));; SHE = (person ((first therese) ,(nat fr) ,(cat ZERO)));; HIM = (person ((first claude) ,(nat fr) ,(cat THREE)));; HER = (person ((first uma) ,(nat usa),(cat FOUR)));; BIG = (person ((first sidarth) ,(nat ind),(cat TWO)));; HEAD = (person ((first moreno) ,(nat it) ,(cat TWO)));; BOSS = (person ((first furio) ,(nat it) ,(cat THREE)));; JEFE = (person ((first maria) ,(nat es) ,(cat ZERO)));; GURU = (person ((first salvador),(nat es) ,(cat TWO)));; DB = (group (ME,YOU,SHE,HIM,HER,BIG,HEAD,JEFE,BOSS,GURU,nil));; *** FINDN : Find the nth Element in a xml catalogue *** [FINDN = ((0,nil) -> fail, ((succ N),(group nil)) -> fail, ((succ 0),(group (X,Y))) -> X, ((succ N),(group (X,Y))) -> (FINDN (N,(group Y))))];; (FINDN (THREE,DB));; *** SELECTIT: Select in a DB the all the items of "it" nationality *** [SELECTIT = ((group (nil)) -> (nil), (group ((person (X,(nat it) ,V)),Z)) -> (group ((person (X,(nat it) ,V)), (SELECTIT (group Z)))), (group ((person (X,(nat fr) ,V)),Z)) -> (SELECTIT (group Z)), (group ((person (X,(nat ind),V)),Z)) -> (SELECTIT (group Z)), (group ((person (X,(nat es) ,V)),Z)) -> (SELECTIT (group Z)), (group ((person (X,(nat usa),V)),Z)) -> (SELECTIT (group Z)))];; (SELECTIT DB);; *** DROPIT: Kill in a DB the all the items of "it" nationality *** [DROPIT =((group (nil)) -> (nil), (group ((person (X,(nat it) ,V)),Z)) -> (DROPIT (group Z)), (group ((person (X,(nat fr) ,V)),Z)) -> (group ((person (X,(nat fr) ,V)), (DROPIT (group Z)))), (group ((person (X,(nat ind),V)),Z)) -> (group ((person (X,(nat ind),V)), (DROPIT (group Z)))), (group ((person (X,(nat es) ,V)),Z)) -> (group ((person (X,(nat es) ,V)), (DROPIT (group Z)))), (group ((person (X,(nat usa),V)),Z)) -> (group ((person (X,(nat usa),V)), (DROPIT (group Z)))))];; (DROPIT DB);; *** DROPC: Kill in a DB the all the items of a given category *** (please reload EQ) EQ = ((0,0) -> true, (0,(succ X)) -> false, ((succ X),0) -> false, ((succ X),(succ Y)) -> (EQ (X,Y)));; [DROPC = ((C,(group (nil))) -> (nil), (C,(group ((person (X,Y,(cat E))),Z))) -> ((group ((person (X,Y,(cat E))),(DROPC (C,(group Z))))) <-? (EQ (C,E)) ?-> (DROPC (C,(group Z)))))];; (DROPC (FOUR,DB));; *** NEW: antipatterns *** antiliteral \toto = match with everithing but toto \\toto = toto (double negation) antivariables \X = match only with an antipattern, otherwise it block the computation. \\X = X double negation **** NOITWFR Kill in a DB the all the items of "it" nationality and move all the other to "fr"*** [NOITWFR = ((group (nil)) -> (nil), (group ((person (X,(nat it),V)),Z)) -> (NOITWFR (group Z)), (group ((person (X,(nat \it),V)),Z)) -> (group ((person (X,(nat fr),V)), (NOITWFR (group Z)))))];; (NOITWFR DB);; *** shorter and/or *** AND = ( (true, true) -> true, \(true,true) -> false);; OR = ( (false,false) -> false, \(false,false) -> true);; *** N O T E !!! which is different from TRY!!! *** AND = ( (true, true) -> true, (\true,\true) -> false);; OR = ( (false,false) -> false, (\false,\false)-> true);; *** NEW: Guarded variables *** X\a = X such that is not equal to a X\Y = X such that is not equal to Y (if Y is bound before) *** NEW DROPIT: Kill in a DB the all the items of "it" nationality *** [DROPIT =((group (nil)) -> (nil), (group ((person (X, (nat it),V)),Z)) -> (DROPIT (group Z)), (group ((person (X,Y\(nat it),V)),Z)) -> (group ((person (X,Y,V)), (DROPIT (group Z)))))];; (DROPIT DB);; (compare with the old one) [DROPIT =((group (nil)) -> (nil), (group ((person (X,(nat it) ,V)),Z)) -> (DROPIT (group Z)), (group ((person (X,(nat fr) ,V)),Z)) -> (group ((person (X,(nat fr) ,V)), (DROPIT (group Z)))), (group ((person (X,(nat ind),V)),Z)) -> (group ((person (X,(nat ind),V)), (DROPIT (group Z)))), (group ((person (X,(nat es) ,V)),Z)) -> (group ((person (X,(nat es) ,V)), (DROPIT (group Z)))), (group ((person (X,(nat usa),V)),Z)) -> (group ((person (X,(nat usa),V)), (DROPIT (group Z)))))];; (DROPIT DB);; *** SELECTIT: Select in a DB the all the items of "it" nationality *** [SELECTIT = ((group (nil)) -> (nil), (group ((person (X, (nat it) ,V)),Z)) -> (group ((person (X,(nat it) ,V)), (SELECTIT (group Z)))), (group ((person (X,\(nat it) ,V)),Z)) -> (SELECTIT (group Z)))];; (SELECTIT DB);; (compare without guarded variables) [SELECTIT = ((group (nil)) -> (nil), (group ((person (X,(nat it) ,V)),Z)) -> (group ((person (X,(nat it) ,V)), (SELECTIT (group Z)))), (group ((person (X,(nat fr) ,V)),Z)) -> (SELECTIT (group Z)), (group ((person (X,(nat ind),V)),Z)) -> (SELECTIT (group Z)), (group ((person (X,(nat es) ,V)),Z)) -> (SELECTIT (group Z)), (group ((person (X,(nat usa),V)),Z)) -> (SELECTIT (group Z)))];; (SELECTIT DB);; *** SELECT: Select in a DB the all the items of a given nationality *** [SELECT = (N,(group (nil))) -> (nil), (N,(group ((person (X,(nat N) ,V)),Z))) -> (group ((person (X,(nat N) ,V)), (SELECT (N,(group Z))))), (N,(group ((person (X,(nat M\N),V)),Z))) -> (SELECT (N,(group Z)))];; (SELECT (es,DB));; *** NEW right-widow rewriting rules Pattern ->| This rule fire, an "effect" (e.g. a I/O operation) is performed. All effects are treated as pattern-matching failures with the NoEffect theory. Examples: (X->| a);; ******************************** * * * One HTML-oriented RHOUTINE * * * ******************************* (Please load) LINK = rhodotinriadotfr;; INDEX = L -> (ohyeahpleaseindex, L);; LOAD = (gigdotinriadotfr -> GIG, cladotinriadotfr -> CLA, hordotinriadotfr -> HOR, rhodotinriadotfr -> RHO, hotdotinriadotfr -> HOT);; GIG = (html ((bal ((bal pc),(bal pc))),(bal ((bal pc),(href rhodotinriadotfr)))));; HOR = (html ((bal (href gigdotinriadotfr),(bal pc)),(bal (bal pc),(bal pc))));; CLA = (html ((bal (bal pc),(bal pc)),(bal (href hordotinriadotfr),(bal pc))));; RHO = (html ((bal (bal pc),(href cladotinriadotfr)),(bal (bal pc),(bal pc))));; *** FINDLINK: find in a web page (recursively) a LINK*** [FINDLINK = (html BODY) -> (FIND BODY) | FIND = ( pc ->| , (bal X) -> (FIND X) , (href LINK) -> (INDEX LINK), (href L\LINK) -> (FINDLINK (LOAD L)), ((href LINK) ,BODY) -> (INDEX LINK), ((href L\LINK) ,BODY) -> ((FINDLINK (LOAD L)),(FIND BODY)), ((bal X) ,BODY) -> ((FIND X) ,(FIND BODY))) ];; (FINDLINK RHO);; (FINDLINK CLA);; (FINDLINK RHO);; *** GOOGLE: find some cycles of lenght 3 in a web page *** WIP.....SORRY... [CYCLES = THREE | LINK = rhodotinriadotfr | GOOGLE = (html BODY) -> ((CYCLES <- THREE); ((FIND BODY) <-? (ISZERO CYCLES) ?-> (INDEX LINK))) | FIND = ( (nil) ->| , pc ->| , (bal pc) ->| , ((href LINK) ,BODY) -> (GOOGLE (html BODY)), ((href L\LINK) ,BODY) -> ((CYCLES = (PRED CYCLES));(GOOGLE (LOAD L))), ((bal X) ,BODY) -> ((FIND X),(FIND BODY)) ) ];; (GOOGLE GIG);; *** NEW Exception !!! Two simple constructions: Handler-Function :-) Protected-Expression and (-: raise-value as a result of evaluating a Protected expression.... *** REVERSE BUT ZERO *** HAND = P -> (ihavefound P);; LIST = (1,2,3,4,5,0,7,8,9,10,nil);; LIST = (1,2,3,4,5,6,7,8,9,10,nil);; [REV = ( (nil,R) -> R, ((0,T),R) -> (-: 0, ((X\0,T),R) -> (REV (T,(X,R))))];; HAND :-) (REV (LIST,(nil)));; *** Negation Normal Form: sharing code *** 1) Some formulas PHI = p;; PHI = (not (not p));; PHI = (not (or (p,p)));; PHI = (not (and (p,q)));; PHI = (and ((and (p,q)),p));; PHI = (and ((not (and (p,q))),(not (and (p,q)))));; [NNF = ( p -> p, q -> q, (not (not X)) -> (NNF X), (not (or (X,Y))) -> (and ((not (NNF X)),(not (NNF Y)))), (not (and (X,Y))) -> (or ((not (NNF X)),(not (NNF Y)))), (and (X,Y)) -> (and ((NNF X),(NNF Y))), (or (X,Y)) -> (or ((NNF X),(NNF Y))))];; (NNF PHI);; [REVERSE = ( (nil,R) -> R, ((0,T),R) -> false, ((X\0,T),R) -> (REVERSE (T,(X,R))))];; (REVERSE (LIST,(nil)));; **** GRAN FINALE: OPTIONAL TYPE SYSTEMS **** A type (inference) system can be used on demand by the user. DATA = 0;; PROGRAM = N ->(succ N);; INFER = X -> false;; HAND = X -> (doesnotcheckandicannotrunmaisjelefaisquandmeme (X dummy));; HAND :-) (-: (dummy -> (PROGRAM DATA)) <-? (INFER (dummy -> (PROGRAM DATA))) ?-> (ihaverun (PROGRAM DATA));; ***WHAT'S NEXT BEFORE SUMMER (V2.0) - IMPLEMENT SECOND ORDER TYPE INFERENCE (FOLLOWING WRLA-02,WRLA-04,REW-WPI3D4) - MORE LIBRHOARY (ala HASKELL PRELUDE.RHO) - OPEN TO OTHER LANGUAGES (WRAPPERS) (FUN~ARG) FUN.py is a python function (PATT -> INPUTS ~> (BODY~INPUTS)) BODY.py is a python function (FUN#ARG) FUN.cs is a (compiled) c# function (PATT #-> BODY) BODY.cs is a (compiled) c# function (FUN$ARG) FUN.java/class is a java standalone function or just javascript (PATT $-> BODY) BODY.java/class is a java standalone function or just javascript Find/Changing Name of the Language: Candidates: 1) keep iRho (very Apple oriented) 2) Symbol (dont need to learn english ;-) 3) Snake (arrow is a snake) ======================== Hoping you enjoyed ... Bye bye Luigi ========================