In article <10edrl7$3v2bf$1@dont-email.me>,   
   Gerry Jackson wrote:   
   >HunptyDumpty introduced his Y Combinator in this post:   
   >https://groups.google.com/g/comp.lang.forth/c/ea59-OtiLvE/m/TH_8t9c7BgAJ   
   >with the definition   
   >: yc ( .. xt xt |0 -- .. ) begin while execute repeat ;   
   >   
   >An example from HD's post:   
   >: downcount dup . 1- dup 0 >= IF xt dup ELSE 0 THEN ;   
   >where xt is the execution token of downcount.   
   >   
   >Having experimented with iterators to avoid having to get the xt of a   
   >word I tried using a quotation:   
   >   
   >: foo [: ;] yc ;   
   >   
      
   I favour the { .. } notation that also replaces :NONAME .. ;   
      
   an index is indispensable in DO , otherwise you have a   
   BEGIN .. WHILE .. REPEAT so no flags.   
   While we are at it:   
   - limits in ascending order   
   - inclusive limits   
   - no unsigned bullshit   
      
   and a DO defined like:   
      
   lowbound upbound(inclusive) xt DO   
   in the body of xt IX is the loop variable.   
   LEAVE works as before.   
    Experiments shows that this works in interpretation mode, thanks to   
    { }   
      
   : foo 1 10 { "we gaan naar Rome" TYPE CR } DO ;   
      
    1 10 { "we gaan naar Rome" TYPE CR } DO   
      
   And you can do things like   
   : foo 1 10 { "we gaan naar Rome" TYPE CR } DO ;   
   : DO) >R >R 0 R> 1- R> ; ( n , range [0,n) ) 1]   
   : DO] >R >R 1 R> R> ; ( n , range (0,n] ) 1]   
      
   And no unsigned indices   
      
   FFFF,FFFF,FFFF,0000 7000,0000,000F,FFFF (empty range nothing happens)   
      
   and no quasi infinite loops like   
   0 0 DO once for index 0.   
      
   (This I have implemented in the experimental language lucky7).   
      
   1] mathematical notation, the upper lower limit is in the set.   
      
   >--   
   >Gerry   
   >   
   --   
   The Chinese government is satisfied with its military superiority over USA.   
   The next 5 year plan has as primary goal to advance life expectancy   
   over 80 years, like Western Europe.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|