Thread: Can you count to ten?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    Code:
    '(1 2 3 4 5 6 7 8 9 10)
    Which is almost a quine, if not for the ' (unquote) character.

    BTW, that is Scheme code which will evaluate to the list of integers from 1 to 10. In Scheme, code is data and vice-versa (mostly).
    Last edited by MacNilly; 11-22-2016 at 01:34 AM.

  2. #2
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    Actually, most Scheme code can evaluate to itself which makes writing quines in Scheme mostly trivial if you can account for the unquote operator.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    BBC Basic

    Code:
    REM 1-10 printing
    REM written by Ada Skyla-Rose
    REM ===================
    FOR i = 1 TO 10
    PRINT i
    NEXT i
    ENDPROC
    END
    Double Helix STL

  4. #4
    Registered User
    Join Date
    Oct 2016
    Location
    Wales, UK
    Posts
    12
    Quote Originally Posted by swgh View Post
    BBC Basic

    Code:
    REM 1-10 printing
    REM written by Ada Skyla-Rose
    REM ===================
    FOR i = 1 TO 10
    PRINT i
    NEXT i
    ENDPROC
    END
    This won't run in BBC BASIC since you haven't defined the procedure. Remove the ENDPROC and it will work - or define the procedure. This will work in BBC BASIC for Windows:

    Code:
          PROC_loop
          PRINT
          PRINT "THE END."
          END
         
          DEF PROC_loop
          FOR I=1 TO 10
            PRINT I;
          NEXT I
          ENDPROC
    ...as will the REPEAT...UNTIL loop in BBC BASIC that I posted earlier on in this thread.

  5. #5
    Registered User
    Join Date
    Oct 2016
    Location
    Wales, UK
    Posts
    12
    May as well add the WHILE...ENDWHILE loop way of doing this in BBC BASIC

    Code:
          
          REM WHILE...ENDWHILE loop BBC BASIC (BBC BASIC for Windows & BBC BASIC V)
          a%=0
          WHILE a%<10
            a%+=1
            PRINT a%
          ENDWHILE
          END

  6. #6
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    You would make a good Java programmer, John

  7. #7
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    What makes you say that?

  8. #8
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Your Haskell is enterprise quality

  9. #9
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Lol I literally just started reading about how in categorical terms an applicative is actually a monoidal functor. I think everything in Haskell is enterprise-quality by nature of the beast XD

    Seriously, the most useless thing ever but I can't pull myself away from it!

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Well, in procedural terms an applicative can be thought of as a function. So, you could say C++ is enterprise-quality.
    The good thing about comparison theorems is that you can always think of an ant as type of elephant.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #11
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Heh heh. Not as much fun as the category theory version though :P

    It's really fun to think about while I'm at work because Lord knows I can't focus on actual work that long.

  12. #12
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    D actually supports a "pure" keyword. I wish C++ did too... :P

    But yeah, the IO monad is basically a way of guaranteeing the same function execution, even if the input is different. Fundamentally, FP is about categories over types and how those types are transformed from one to the other. The type system does help keep things in line but that's more or less because it represents a functor and how functors transform categories.

  13. #13
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by MutantJohn View Post
    D actually supports a "pure" keyword. I wish C++ did too... :P
    It's not as useful as it seems. Purity is trivial to statically prove. And it doesn't help with CTFE, since if you want to guarantee it, the expression in question should be decorated as such, which C++ does have, in the form of constexpr.

  14. #14
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Apl:
    Code:
    ⍳10

  15. #15
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    However let it be said that the only correct way to program BBC BASIC today is to program it wrong.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Uppercase/Lowercase/Word COunt/Char count
    By Charak in forum C Programming
    Replies: 7
    Last Post: 02-23-2011, 08:16 AM
  2. Even I Can Count Better Than That...
    By pianorain in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 12-02-2005, 07:17 PM
  3. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM
  4. Replies: 2
    Last Post: 05-05-2002, 01:38 PM

Tags for this Thread