|
From: Slobodan Blazeski on 6 May 2008 12:18 On May 6, 4:45 pm, Slobodan Blazeski <slobodan.blaze...(a)gmail.com> wrote: > On May 6, 4:23 pm, Slobodan Blazeski <slobodan.blaze...(a)gmail.com> > wrote: > > > > > > > On May 5, 3:00 pm, Ken Tilton <kennytil...(a)optonline.net> wrote: > > > > Slobodan Blazeski wrote: > > > > On May 4, 4:15 am, Ken Tilton <kennytil...(a)optonline.net> wrote: > > > > >>Slobodan Blazeski wrote: > > > > >>>On May 2, 1:00 pm, "John Thingstad" <jpth...(a)online.no> wrote: > > > > >>>>På Fri, 02 May 2008 05:02:03 +0200, skrev Ken Tilton > > > >>>><kennytil...(a)optonline.net>: > > > > >>>>>Everyone knows how much I love Arc, I guess it has influenced my Lisp: > > > > >>>>>(deftoc |Reducing| > > > >>>>> (category "Algebra I" "Fractions") > > > >>>>> (genner > > > >>>>> (easy > > > >>>>> (w (n (rr 2 6)) > > > >>>>> (m/ n (* n (rr 2 9))))) > > > >>>>> (avg > > > >>>>> (dsb (n d cf) > > > >>>>> (sort (rpu 3 (rr 2 9)) '<) > > > >>>>> (m/ (* n cf) (* d cf)))) > > > >>>>> (hard > > > >>>>> (dsb (n d cf) > > > >>>>> (rpu 3 (rr 2 12)) > > > >>>>> (m/ (* n cf) (* d cf))) > > > >>>>> (dsb (n1 n2 d1 d2) > > > >>>>> (subseq (shuffle (list 2 3 5 7 9 11 13)) 0 4) > > > >>>>> (m/ (* n1 n2) (* d1 d2)))))) > > > > >>>>>[The neat thing being one DSL within another DSL. (This Algebra > > > >>>>>application just screams for DSLs because of the repeated coding of > > > >>>>>different Algebraic transformations.)] > > > > >>>>>Btw, the "genner" clause hard-codes random problem generation. > > > > >>>>>Hmmm. Where'd the prolog go? Ah, different problem (halfway down): > > > > >>>>>(deftoc add-real > > > >>>>> (title "Adding") > > > >>>>> (category "Algebra I" "Real Numbers") > > > >>>>> (genner > > > >>>>> (easy > > > >>>>> (m+ (rp 2 (r+ 12))) > > > >>>>> (m+ (rp 2 (r- 12))) > > > >>>>> (eo (m+ 0 (r+ 12)) > > > >>>>> (m+ (r+ 12) 0)) > > > >>>>> (w (n (r+ 12)) > > > >>>>> (eo (m+ n (- n)) > > > >>>>> (m+ (- n) n)))) > > > >>>>> (avg > > > >>>>> ;; --- two approaches to same thing, without prolog.. > > > >>>>> (w (ns (rpu 2 (r+ 12))) > > > >>>>> (eo (m+ (car ns) (- (cadr ns))) > > > >>>>> (m+ (- (car ns)) (cadr ns)))) > > > >>>>> ;; ---- ...and with prolog > > > >>>>> (plogn > > > >>>>> (generating ?x (fgen (random 12))) > > > >>>>> (generating ?y (fgen (random 12))) > > > >>>>> (lispp (/= ?x ?y)) > > > >>>>> (eo (m+ ?x (- ?y)) > > > >>>>> (m+ (- ?x) ?y)))) > > > >>>>> (hard > > > >>>>> (plogn > > > >>>>> (generating ?ns (fgen (rp (eo 3 4) (eo (r+ 12)(r- 12))))) > > > >>>>> (lispp (and (+? (ct-if '+? ?ns)) > > > >>>>> (+? (ct-if '-? ?ns)))) > > > >>>>> (m+ ?ns))))) > > > > >>>>>I highlighted above a for-the-fun-of-it with/without Prolog pair, > > > >>>>>fascinating that the prolog variant is so much easier to code and so > > > >>>>>much more verbose. Usually goes the other way. > > > > >>>>>Anyway, looking ahead I can almost guarantee the prolog approach will > > > >>>>>win out -- I have been through this before. In C. Twenty years ago. I > > > >>>>>haven't forgotten the agony of enforcing constraints in procedural code. > > > > >>>>>Meanwhile, what a pleasure to be doing /applications/ again with Lisp, > > > >>>>>erecting version 1.0 of a random problem generation framework in an easy > > > >>>>>day. Noobs, as much as you dig Lisp, have no idea how much fun it will > > > >>>>>be three years in when it disappears and you can Just Build Apps. > > > > >>>>>kenny > > > > >>>>Just in case I am not on your "kill" list. I have sided with Pascal in > > > >>>>that full words are better. > > > > >>>I vote for full words , though look at a dictionary and try to find > > > >>>shortest synonym. > > > >>>Very-long-and-descriptive-names sucks. But code that looks like a > > > >>>three-year-old with a particular fondness for periods and colons was > > > >>>set before the keyboard. (http://www.jsoftware.com/help/jforc/contents.htm) > > > > >>This is very disappointing. > > > > >>We already have on the table Tilton's Law of Abbreviation, signifying my > > > >>concurrence with the general rule, and I have gone to the trouble of > > > >>pointing out why this situation is exceptional, yet not not one of you > > > >>has said one word addressing the validity of the exception, which is the > > > >>only issue on the table given my concurrence with the general rule. > > > > >>The earnest dullard can follow rules, the craftsman knows when they do > > > >>not apply. This is the thing we cannot teach, to expert systems or even > > > >>good students. It requires a meta-understanding of the rule, an > > > >>understanding of from where the rule came and then whether the > > > >>circumstances at hand come from the same place. > > > > >>And what do I hear from You People? A cast in concrete knee-jerk rote > > > >>repeating snap-saluting line-toeing mindless recitation of something you > > > >>read in chapter 3 of a programming proverbs book. > > > > >>Super. You got 5 points from your teacher who was looking for The One > > > >>Right Answer and you just flunked out of the U. of Kenny. > > > > > Kenny I've read your explanation but I still disagree with you it has > > > > nothing to do listening some teacher or fallowing some cast in > > > > concrete rule. It just the way I feel it's right. > > > > Take for example assignment operator: > > > > cl setf > > > > scheme set! > > > > q : > > > > j =: > > > > c++ = > > > > > For anybody using the language more than 3 days it would be crystal > > > > clear what this do.Because we're getting use to parse those *symbols*. > > > > Also in case of c++ we have even different meaning, because = in math > > > > means SAME. In case of j we have to understand what's that strange > > > > equal. > > > > But what if we use ASSIGN like (assign foo 4) <=> (setf foo 4) Assign > > > > is already prebuilt in our knowledge of english meaning we don't hog > > > > any more of our brain resources to parse the setf set! or : It's > > > > longer but tolerable. We have to type 6 characters but we release our > > > > brain resources from context switching and symbol lookup. If we are so > > > > on shortness maybe using IS is better. Not clear as ASSIGN but still > > > > brain resources are lower. Think (is foo 4) or in tradition syntax foo > > > > is 4; // looks like cobol? So adding a lot of meaningless > > > > abbreviations like above is just not my style. Your brain might > > > > function differently, but I have a natural tendency to remove brain > > > > hogging coming from long functions, abreviations or shortcuts. I know > > > > that each thing takes only a negligeble thing but they quickly add up. > > > > This is the reason I don't like Emacs YMMV. > > > > Jeez, it's a simple question: > > > > This?: > > > > (mx-generate #\- > > > (mx-generate #\* > > > (random-in-range 2 9) > > > (random-in-range 2 9)) > > > (random-in-range 2 9)) > > > > ...or this: > > > > (m- (m* (rr 2 9)(rr 2 9)) > > > (rr 2 9))) > > > > ...or maybe something infixy and even closer to what I am trying to > > > express (hint) like this: > > > > "r2[9]*r2[9]-r2[9]" > > > > ...or some other infix/string scheme? > > > In Edi > > (hook (create #\-) (create #\* dup) (random 2 9)) > > Where: > > 1. (hook fn1 fn2 atom) => (fn (fn2 atom) atom)) > > 2. If (define create (x &rest args) ...) then > > (create #\-) => (lambda (&rest args) (apply create #\- args)) > > 3. Dup is a operator that tells how many copies of the argument > > should be supplied : > > (m* (rr 2 9)(rr 2 9) (rr 2 9)) <=> (m* (dup 2) > > 4. (random x y) is ... you know > > Sorry I forget to give you a credit for in-the-name instructions, edi > is polymorhic, so what if there is monadic create then below wouldn't > work > (create #\-) => (lambda (&rest args) (apply create #\- args)) sp using > in-the-name instructions > (create\2 #\-) meaning I'm talking about dyadic create. Something > they're nifty but I prefer to avoid them so final result > (hook (create\2 #\-) (create\2 #\* dup) (random 2 9)) or > (hook (dyad create #\-) (dyad create #\* dup) (random 2 9))- Hide quoted text - > > - Show quoted text - My mistake, you can't use hook because you'll only get a single random so you're stack with (create #\- (create #\* (random 2 9) (random 2 9)) (random 2 9)) as random is not a functional operator. |