Arc Forumnew | comments | leaders | submitlogin
Can you spot my error? Newbie question
2 points by forensic 5908 days ago | 7 comments
I wrote this code just to see how ridiculous I could be. Arc doesn't accept the function no matter how many closing brackets I use.

Any help?

(def beer (x) (with (y t z x) (while (is y t) (do (prn (if (is x 0) "No more" x) " bottle" (if (is x 1) "" "s") " of beer on the wall, " (if (is x 0) "no more" x) bottle" (if (is x 1) "" "s") " of beer!") (if (is x 0) (do (prn "Go to the store and buy some more, " z " bottle" (if (is z 1) "" "s") " of beer on the wall!") (= y nil)) (prn "You take one down, pass it around, " (if (is (- x 1) 0) "no more" (- x 1)) " bottle" (if (is (- x 1) 1) "" "s") " of beer on the wall!")) (prn) (= x (- x 1))))))

(edit: sorry, i'm trying to get the code formatting to work but I can't seem to get it.

"Text after a blank line that is indented by two or more spaces is reproduced verbatim."

I don't know why it's not working)



4 points by stefano 5908 days ago | link

You forgot a #\" before bottle".

  (def beer (x)
    (with (y t z x)
      (while (is y t)
        (do 
          (prn (if (is x 0) "No more" x) 
               " bottle" ; *** here the error
               (if (is x 1) "" "s")
               " of beer on the wall, " 
               (if (is x 0) "no more" x)
               " bottle" 
              (if (is x 1) "" "s") 
              " of beer!")
          (if (is x 0) 
           (do 
             (prn "Go to the store and buy some more, "
                  z " bottle" (if (is z 1) "" "s")
                  " of beer on the wall!")
             (= y nil))
           (prn "You take one down, pass it around, " 
                (if (is (- x 1) 0) "no more" (- x 1)) 
                " bottle" (if (is (- x 1) 1) "" "s") 
                " of beer on the wall!"))
          (prn) 
          (= x (- x 1))))))

-----

2 points by rincewind 5906 days ago | link

This should be part of Anarki, so Arc can have the second shortest "99 bottles of beer" program of all langauges ...

-----

1 point by forensic 5906 days ago | link

Which language would have the shortest?

I found a site that lists "99 bottles" programs in 1000 languages, but they don't correct for proper grammar and they don't accept inputs that aren't 99. One guy wrote a shorter 99 bottles program in Arc but it used more high-level functions than mine did.

I can't think of a language that could do the proper grammar, accepting any initial # of bottles, with fewer tokens than Arc.

-----

2 points by rincewind 5906 days ago | link

HQ9+

It is an esoteric language, designed to have the shortest programs for "Hello, World!" "99 bottles of beer" and quines.

http://99-bottles-of-beer.net/language-hq9+-1334.html

http://esolangs.org/wiki/HQ9_Plus

-----

1 point by forensic 5908 days ago | link

Thank you, but could you elaborate a little please? I guess I don't understand how to use #\ properly.

-----

3 points by fallintothis 5908 days ago | link

#\x is just the character literal for the letter x -- each element of a string being a character. What the parent means is that you forgot to put a quotation mark before the mentioned line. You don't need to use #\ in this context, but in writing it makes more sense than saying you forgot a " before bottle".

-----

1 point by forensic 5908 days ago | link

Thank you sir. It is clear to me now.

-----