(defun continued-fraction (real)
(multiple-value-bind (integer-part fractional-part)
(floor (rationalize real))
(cons integer-part (if (zerop fractional-part)
nil
(continued-fraction (/ 1 fractional-part))))))
What does /prog/ think? Am I shooting myself in the foot by just throwing rationalize in there and hoping it works out?
>>9
Yeah, but to get results from a floating point input you've got to convert it to a rational... and if you divide out the fraction returned by that second function (written by someone other than OP, BTW), you'll get something other than the input that would make continued-fraction yield the continued fraction given to the second function.
>>16
Yes, every recursive function in lisp looks the same. I just wrote this this second to show OP how shitty his style is though.
Name:
Anonymous2007-09-03 16:01 ID:1WCt9T06
PROTIPS:
* (/ 1 x) ≡ (/ x)
* &aux 4lyfe
* name things PROPERLY, as if you aren't a FAGGOT
* (if x nil y) FAGGOTRY! use (when x y) instead
* ZEROP?? are you fucking [b]GAY[/b] or somthing?
* there is so fucking much wrong with your 5 lines of shit code OP, I desipair
Name:
Anonymous2007-09-03 16:01 ID:Yg9/l8CK
>>17
I especially like the way you replaced every meaningful name in the function with something worse. That was a real brainstorm.
Name:
Anonymous2007-09-03 16:03 ID:1WCt9T06
>>19
learn english, his code is far better than yours
Name:
Anonymous2007-09-03 16:07 ID:Yg9/l8CK
He has me on / and if instead of unless, but fails it completely on all other counts.
* &aux -- why?
* ensure? coefficient does not mean that.
* zerop 4lyfe
>>24
As tempting as using &aux to look cool is, it's not like I added an extra let form or anything. I just threw in a rationalize where it needed to be rather than creating extra variable names and doing more typing.
Name:
Anonymous2007-09-03 16:26 ID:Yg9/l8CK
Lol, from http://www.lisp.org/table/style.htm: # Don't use the &AUX lambda-list keyword. It is always clearer to define local variables using LET or LET*.
ITT we shoot our mouths off and get caught.
Name:
Anonymous2007-09-03 16:45 ID:1WCt9T06
>>27
App-ppp-pp-eal to authority!!!
Always wins every argument
lisp.org is a costly domain, so anything written there MUST be right!
Name:
Anonymous2007-09-03 16:48 ID:Yg9/l8CK
>>28
4chan.org can be posted on by anybody, so anything written there MUST be right!
Face it, you don't know shit about Lisp (&aux, zerop), English (coefficient, WTF), or LIFE.
;;; Found replace-all on http://cl-cookbook.sourceforge.net/strings.html
(defun replace-all (string part replacement &key (test #'char=))
"Returns a new string in which all the occurences of the part
is replaced with replacement."
(with-output-to-string (out)
(loop with part-length = (length part)
for old-pos = 0 then (+ pos part-length)
for pos = (search part string
:start2 old-pos
:test test)
do (write-string string out
:start old-pos
:end (or pos (length string)))
when pos do (write-string replacement out)
while pos)))
Name:
Anonymous2007-09-04 2:27 ID:+mjGaGsI
>>29
Give it up, kid. You don't know SHIT about JAPAN.
>>35
gross dude, Fuck you and fuck your code
Get the fuck off /prog/
this is the most horrible shit ever, no wonder people dont like lisp with fucking noobs like you write code this vile