Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. That's one way to do it

That's one way to do it

Scheduled Pinned Locked Moved The Weird and The Wonderful
comhelp
64 Posts 38 Posters 39 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Kent Sharkey

    GitHub - samuelmarina/is-even[^]

    Quote:

    This is a 100% serious project, and it is made to help the community.

    A brief excerpt:

    function isEven(number) {
    if(number === 1) return false;
    else if(number === 2) return true;
    else if(number === 3) return false;
    else if(number === 4) return true;
    else if(number === 5) return false;
    else if(number === 6) return true;
    else if(number === 7) return false;

    They're up to 1,000,001 now. Help them grow! :doh:

    TTFN - Kent

    S Offline
    S Offline
    Slow Eddie
    wrote on last edited by
    #21

    What? :confused: I am probably dumb, or inexperienced, or both, but I see no practical use for this.:confused:

    Zaphod

    1 Reply Last reply
    0
    • P Peter Kelley 2021

      I'm sure this project is a gag! (and I'm snickering!) Has anyone yet suggested porting this to some cloud-native database of the even numbers? :)

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #22

      Feel free to suggest it[^]. :laugh:


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • K Kent Sharkey

        GitHub - samuelmarina/is-even[^]

        Quote:

        This is a 100% serious project, and it is made to help the community.

        A brief excerpt:

        function isEven(number) {
        if(number === 1) return false;
        else if(number === 2) return true;
        else if(number === 3) return false;
        else if(number === 4) return true;
        else if(number === 5) return false;
        else if(number === 6) return true;
        else if(number === 7) return false;

        They're up to 1,000,001 now. Help them grow! :doh:

        TTFN - Kent

        E Offline
        E Offline
        englebart
        wrote on last edited by
        #23

        Thanks for sharing this… I was looking for a way to stripe my html tables!

        1 Reply Last reply
        0
        • K Kent Sharkey

          GitHub - samuelmarina/is-even[^]

          Quote:

          This is a 100% serious project, and it is made to help the community.

          A brief excerpt:

          function isEven(number) {
          if(number === 1) return false;
          else if(number === 2) return true;
          else if(number === 3) return false;
          else if(number === 4) return true;
          else if(number === 5) return false;
          else if(number === 6) return true;
          else if(number === 7) return false;

          They're up to 1,000,001 now. Help them grow! :doh:

          TTFN - Kent

          A Offline
          A Offline
          atverweij
          wrote on last edited by
          #24

          That can be done better with a recursive function:

          function IsEven(number) {
          if (number === 1 return false;
          elseif (number === 2) return true;
          else return IsEven(number - 2);
          }

          Now it does all positive numbers :laugh: EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.

          D B B K 4 Replies Last reply
          0
          • A atverweij

            That can be done better with a recursive function:

            function IsEven(number) {
            if (number === 1 return false;
            elseif (number === 2) return true;
            else return IsEven(number - 2);
            }

            Now it does all positive numbers :laugh: EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.

            D Offline
            D Offline
            dandy72
            wrote on last edited by
            #25

            Points for being clever. Sadly, someone would still use it...

            A 1 Reply Last reply
            0
            • K Kent Sharkey

              GitHub - samuelmarina/is-even[^]

              Quote:

              This is a 100% serious project, and it is made to help the community.

              A brief excerpt:

              function isEven(number) {
              if(number === 1) return false;
              else if(number === 2) return true;
              else if(number === 3) return false;
              else if(number === 4) return true;
              else if(number === 5) return false;
              else if(number === 6) return true;
              else if(number === 7) return false;

              They're up to 1,000,001 now. Help them grow! :doh:

              TTFN - Kent

              M Offline
              M Offline
              MarkTJohnson
              wrote on last edited by
              #26

              I'm trying to guess what certain CPers would do if they were confronted with this person. JSOP - bullet in the guy's head to put both the guy and everyone else out of their misery. honey the codewitch - After she quit twitching, she'd write a parser to optimize the code. OriginalGriff - figures out how to turn it into a CCC clue Nagy - just wanders off, asking where the gin is. Me - I'd tell him to turn it all into a switch statement.

              I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.

              W D 2 Replies Last reply
              0
              • K Kent Sharkey

                GitHub - samuelmarina/is-even[^]

                Quote:

                This is a 100% serious project, and it is made to help the community.

                A brief excerpt:

                function isEven(number) {
                if(number === 1) return false;
                else if(number === 2) return true;
                else if(number === 3) return false;
                else if(number === 4) return true;
                else if(number === 5) return false;
                else if(number === 6) return true;
                else if(number === 7) return false;

                They're up to 1,000,001 now. Help them grow! :doh:

                TTFN - Kent

                K Offline
                K Offline
                Kirk 10389821
                wrote on last edited by
                #27

                You know... It's 2021, and the IRONY flows freely in all things... I expected to see a macro (written in JavaScript), that writes the javascript file: for (x..) if x % 1 == 0 write "if (number == " + x +") return false;" else write "if (number == " + x +") return true;" == And to see him asking people to crowd source running that file, to help him out! == Next question... Where is his test harness... Or is he caught in an infinite loop?

                1 Reply Last reply
                0
                • D dandy72

                  Points for being clever. Sadly, someone would still use it...

                  A Offline
                  A Offline
                  atverweij
                  wrote on last edited by
                  #28

                  If someone really uses it, he or she deserves it ;P

                  D 1 Reply Last reply
                  0
                  • M MarkTJohnson

                    I'm trying to guess what certain CPers would do if they were confronted with this person. JSOP - bullet in the guy's head to put both the guy and everyone else out of their misery. honey the codewitch - After she quit twitching, she'd write a parser to optimize the code. OriginalGriff - figures out how to turn it into a CCC clue Nagy - just wanders off, asking where the gin is. Me - I'd tell him to turn it all into a switch statement.

                    I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.

                    W Offline
                    W Offline
                    wapiti64
                    wrote on last edited by
                    #29

                    I'd side with JSOP, after I made them delete everything.

                    1 Reply Last reply
                    0
                    • K Kent Sharkey

                      GitHub - samuelmarina/is-even[^]

                      Quote:

                      This is a 100% serious project, and it is made to help the community.

                      A brief excerpt:

                      function isEven(number) {
                      if(number === 1) return false;
                      else if(number === 2) return true;
                      else if(number === 3) return false;
                      else if(number === 4) return true;
                      else if(number === 5) return false;
                      else if(number === 6) return true;
                      else if(number === 7) return false;

                      They're up to 1,000,001 now. Help them grow! :doh:

                      TTFN - Kent

                      J Offline
                      J Offline
                      John Wellbelove
                      wrote on last edited by
                      #30

                      They've missed a whole set of entries for those that speak British style English. American: Thirty-Two Thousand One Hundred Twelve British: Thirty-Two Thousand One Hundred And Twelve I'd better get editing...

                      Richard DeemingR M 2 Replies Last reply
                      0
                      • A atverweij

                        If someone really uses it, he or she deserves it ;P

                        D Offline
                        D Offline
                        dandy72
                        wrote on last edited by
                        #31

                        Sometimes the best thing you can do is let others hang themselves. Figuratively speaking. :~

                        1 Reply Last reply
                        0
                        • J John Wellbelove

                          They've missed a whole set of entries for those that speak British style English. American: Thirty-Two Thousand One Hundred Twelve British: Thirty-Two Thousand One Hundred And Twelve I'd better get editing...

                          Richard DeemingR Offline
                          Richard DeemingR Offline
                          Richard Deeming
                          wrote on last edited by
                          #32

                          Someone's already beaten you to that suggestion: [Feature Request] Support for British English "and" · Issue #85 · samuelmarina/is-even · GitHub[^] :-D


                          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                          N 1 Reply Last reply
                          0
                          • A atverweij

                            That can be done better with a recursive function:

                            function IsEven(number) {
                            if (number === 1 return false;
                            elseif (number === 2) return true;
                            else return IsEven(number - 2);
                            }

                            Now it does all positive numbers :laugh: EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.

                            B Offline
                            B Offline
                            BruceCarson
                            wrote on last edited by
                            #33

                            No...only positive integers. Since this is JS, some jerk could pass a float in and get your recursive function to march off the negative end of the numbers.

                            A 1 Reply Last reply
                            0
                            • B BruceCarson

                              No...only positive integers. Since this is JS, some jerk could pass a float in and get your recursive function to march off the negative end of the numbers.

                              A Offline
                              A Offline
                              atverweij
                              wrote on last edited by
                              #34

                              Hmmm, you are right. The the improved improved version.

                              function IsEven(number) {
                              if (number === 1) return false;
                              else if (number ===2) return true;
                              else if (number > 2) return IsEven(number - 2);
                              else return IsEven(number + 2)
                              }

                              Now it does negatives too ;P EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.

                              B K 2 Replies Last reply
                              0
                              • J John Wellbelove

                                They've missed a whole set of entries for those that speak British style English. American: Thirty-Two Thousand One Hundred Twelve British: Thirty-Two Thousand One Hundred And Twelve I'd better get editing...

                                M Offline
                                M Offline
                                MarkTJohnson
                                wrote on last edited by
                                #35

                                The AND denotes the decimal or fractional portion of the number. So Brits in the example above, Twelve whats?

                                I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.

                                Richard DeemingR J 2 Replies Last reply
                                0
                                • A atverweij

                                  Hmmm, you are right. The the improved improved version.

                                  function IsEven(number) {
                                  if (number === 1) return false;
                                  else if (number ===2) return true;
                                  else if (number > 2) return IsEven(number - 2);
                                  else return IsEven(number + 2)
                                  }

                                  Now it does negatives too ;P EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.

                                  B Offline
                                  B Offline
                                  BruceCarson
                                  wrote on last edited by
                                  #36

                                  And now this line of code is used: IsEven (4.2); It'll bounce around 0 until the heat death of the universe.

                                  A 1 Reply Last reply
                                  0
                                  • A atverweij

                                    Hmmm, you are right. The the improved improved version.

                                    function IsEven(number) {
                                    if (number === 1) return false;
                                    else if (number ===2) return true;
                                    else if (number > 2) return IsEven(number - 2);
                                    else return IsEven(number + 2)
                                    }

                                    Now it does negatives too ;P EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.

                                    K Offline
                                    K Offline
                                    kalberts
                                    wrote on last edited by
                                    #37

                                    Why are all the 'else's there? Do they improve code generation?

                                    A 1 Reply Last reply
                                    0
                                    • M MarkTJohnson

                                      The AND denotes the decimal or fractional portion of the number. So Brits in the example above, Twelve whats?

                                      I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.

                                      Richard DeemingR Offline
                                      Richard DeemingR Offline
                                      Richard Deeming
                                      wrote on last edited by
                                      #38

                                      Not in British English (or just "English", as it's known). :) "One hundred and twelve" === 112, not 100.12.


                                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                                      1 Reply Last reply
                                      0
                                      • P PIEBALDconsult

                                        function isOdd(x) { return isEven(x**-1**); } ? function isOdd(x) { return isEven(**~**x); } ?

                                        J Offline
                                        J Offline
                                        jsc42
                                        wrote on last edited by
                                        #39

                                        PIEBALDconsult wrote:

                                        function isOdd(x) { return isEven(x**-1**); }

                                        The sad thing is that that wouldn't work when testing against '1' as that would be testing to see if 0 was even and their isEven does not have a test for 0.

                                        1 Reply Last reply
                                        0
                                        • M MarkTJohnson

                                          The AND denotes the decimal or fractional portion of the number. So Brits in the example above, Twelve whats?

                                          I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.

                                          J Offline
                                          J Offline
                                          John Wellbelove
                                          wrote on last edited by
                                          #40

                                          The British English convention is to put an 'and' between any hundreds and non-zero tens/units and 'point' to indicate the fraction part. Therefore 123,456.789 is... "One hundred and twenty three thousand, four hundred and fifty six point seven, eight, nine"

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups