Only authorized users are allowed to upload new attachments.

This page (revision-5) was last changed on 08-Aug-2010 11:26 by Carsten Strotmann

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

#### Difference between version 5 4 3 2 1 and 5 4 3 2 1

 At line 68 changed one line Figure 2a would look as shown in Figure 3. Let's add two more spoons of syntactic sugar, as in Figure 4. As has been noted elsewhere, too much syntactic sugar causes semantic diabetes. Our __case__ is sweet enough. Figure Five is an example to show some of the possibilities. Figure 2b {{{ craps(n) int n; { switch(n) { case 7, 11: printf("You win"); break; case 2..3, 12: printf("You lose"); break; default: printf("%d is you point",n); } } }}} At line 80 added 38 lines Figure 3 {{{ : CASE DUP ; : CRAPS ( n -- ) CASE 7 = IF DROP ." You win" EXIT THEN CASE 11 = IF DROP ." You win" EXIT THEN CASE 2 = IF DROP ." You lose" EXIT THEN CASE 3 = IF DROP ." You lose" EXIT THEN CASE 12 = IF DROP ." You lose" EXIT THEN . . is your point" ; }}} Figure 2a would look as shown in Figure 3. Let's add two more spoons of syntactic sugar, as in Figure 4. As has been noted elsewhere, too much syntactic sugar causes semantic diabetes. Our __case__ is sweet enough. Figure 5 is an example to show some of the possibilities. Figure 3 {{{ : OF ( n flag -- ) [COMPILE] IF COMPILE DROP ; IMMEDIATE : =OR ( n flag n -- n flag ) 2 PICK = DROP ; : CRAPS ( n -- ) CASE 7 = 11 =OR OF ." You win" EXIT THEN CASE 2 3 BETWEEN 12 =OR OF ." You lose" EXIT THEN . ." is your point" ; }}} Figure 4 {{{ : WHATEVER ( n -- ) CASE 0= OF ." zero" EXIT THEN CASE 0< OF ." Negative" EXIT THEN CASE DUP 1- AND 0= OF ." Power of 2" EXIT THEN CASE ASCII 0 ASCII 9 BETWEEN OF ." Digit" EXIT THEN CASE ASCII , ASCII / BETWEEN ASCII : =OR OF ." Punctuation ,-./: " EXIT THEN DROP ." Whatever" ; }}}
Version Date Modified Size Author Changes ... Change note
5 08-Aug-2010 11:26 9.406 kB Carsten Strotmann to previous
4 08-Aug-2010 11:02 7.089 kB Carsten Strotmann to previous | to last
3 08-Aug-2010 10:46 5.883 kB Carsten Strotmann to previous | to last
2 08-Aug-2010 10:34 2.953 kB Carsten Strotmann to previous | to last
1 08-Aug-2010 10:30 2.667 kB Carsten Strotmann to last
« This page (revision-5) was last changed on 08-Aug-2010 11:26 by Carsten Strotmann
G’day (anonymous guest) My Prefs