/-/S'pht-Translator-Active/-/


Re: Error
Posted By: thermoplyaeDate: 3/31/07 8:13 a.m.

In Response To: Re: Error (My Name)

: underwhelming? What were you expecting? Errors on the 7 page are not
: acceptable. /weird /dying fore'um

I thought you were presenting the information for the first time, and I didn't spot the error until just now. My mistake. I'm too used to being hostile. ;P

Hamish isn't perfect, sadly; good thing the pattern holds anyway and the original poster was correct. :)

For your own print-out, throw this in your favorite Common Lisp interpreter. Modify the bound of the loop on the last line (it's 13 right now) to get more or fewer numbers (note that this is ugly because it's tail recursive, which lets you bring up the list bound pretty stunningly high without any memory issues):

(defun pow (base exp) (labels ((po (base exp acc) (if (zerop exp) acc (po base (1- exp) (* acc base))))) (po base exp 1)))
(defun collapse (n) (labels ((coll (n) (labels ((col (n acc) (if (zerop n) acc (col (truncate (/ n 10)) (+ acc (mod n 10)))))) (col n 0)))) (let ((i (coll n))) (if (< i 10) i (collapse i)))))
(dotimes (i 13) (format t "7 to the power of ~d = ~d which reduces to ~d~%" i (truncate (pow 7 i)) (collapse (truncate (pow 7 i)))))

[ Post a Reply | Message Index | Read Prev Msg | Read Next Msg ]
Pre-2004 Posts

Replies:

Where's ole Hamish?Nerem 3/27/07 6:54 a.m.
     Re: Where's ole Hamish?thermoplyae 3/27/07 7:34 a.m.
           ErrorMy Name 3/30/07 7:27 p.m.
                 Re: Errorthermoplyae 3/30/07 8:29 p.m.
                       Re: ErrorMy Name 3/30/07 9:10 p.m.
                             Re: Errorkyjel 3/30/07 10:50 p.m.
                             Re: Errorthermoplyae 3/31/07 8:13 a.m.

[ Post a Reply | Message Index | Read Prev Msg | Read Next Msg ]
Pre-2004 Posts

 

 

Your Name:
Your E-Mail Address:
Subject:
Message:

If you'd like to include a link to another page with your message,
please provide both the URL address and the title of the page:

Optional Link URL:
Optional Link Title:

If necessary, enter your password below:

Password:

 

 

Problems? Suggestions? Comments? Email maintainer@bungie.org

Marathon's Story Forum is maintained with WebBBS 5.12.