Message from discussion
bignums in clisp
Received: by 10.180.106.102 with SMTP id gt6mr2254915wib.0.1349940278689;
Thu, 11 Oct 2012 00:24:38 -0700 (PDT)
Path: q10ni65082042wif.0!nntp.google.com!feeder1.cambriumusenet.nl!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!usenetcore.com!border1.nntp.ams.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!backlog2.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Newsgroups: comp.lang.lisp
Subject: Re: bignums in clisp
Date: Wed, 03 Oct 2012 13:27:21 +0200
Organization: Informatimago
Lines: 49
Message-ID: <871uhfvlra.fsf@kuiper.lan.informatimago.com>
References: <7c6cd833-2c5b-43a4-9825-7fd540ece54a@googlegroups.com>
<87627jgmta.fsf@gnu.org> <k44gnl$o33$1@news.ox.ac.uk>
<barmar-ABCFBE.16040128092012@news.eternal-september.org>
<20120928140653.318@kylheku.com>
<barmar-4DCE69.21544929092012@news.eternal-september.org>
<k4ev7v$gp7$1@news.ox.ac.uk> <k4f0j3$r38$1@reader1.panix.com>
<87obkkvr1e.fsf@kuiper.lan.informatimago.com>
<k4g5gg$ftb$1@reader1.panix.com> <k4h12a$7t7$1@news.ox.ac.uk>
Mime-Version: 1.0
X-Trace: individual.net ClDNXjLSCEdFFTuup5FVrwg2dOzWQu+WyqTttZINwKe3Lbfyrt
Cancel-Lock: sha1:YWVkZjQ0MzQzZmMxMzAxYjZhMTc4YTdkYWIxNjE2NjZkMTBjMzdmMQ== sha1:BzMrXJJXjI9BYHDtVRjFoKm4otA=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA
oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9
033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac
l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR
mV+hO/VvFAAAAABJRU5ErkJggg==
X-Accept-Language: fr, es, en
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
X-Original-Bytes: 3432
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Ian Clifton <ian.clif...@chem.ox.ac.uk> writes:
> Sorry! I just thought it was interesting that such a scheme could (I
> think) be implemented (although you’d have to work out how to do
> indexing of data structures by bignum etc), even though we all know it
> couldn’t possibly work in any useful sense. I recall that Bart Simpson
> once lined up several police bull†horns, the output of one feeding into
> the microphone of the next, in order to produce a stupendously loud
> sound. Of course this wouldn’t work either, but you could attempt the
> experiment.
Well we're speaking of lisp here, so there's a solution. It's easy to
represent a number bigger than the universe in lisp: just use a sexp!
(↑↑↑↑ 3 3)
(↑27↑ 3 3)
(lessp '(↑27↑ 3 3) (add '(↑27↑ 3 3) '(↑↑↑↑ 3 3)))
(defun ↑ (x y) (expt x y))
(defun ↑↑ (x y) (expt x (expt y y)))
(defun ↑↑↑ (x y) (expt x (expt y (expt y y))))
(defun ↑↑↑↑ (x y) (expt x (expt y (expt y (expt y y)))))
(↑↑ 3 3) --> 7625597484987
(↑↑↑ 3 3) can't be computed on current hardware, but you can still
represent this number, as the sexp (↑↑↑ 3 3), like you can represent 100
as: (* (expt 5 2) (expt 2 2)) or some other sexp.
And you can write functions like add and lessp that compute
symbolically. (You can use a theorem prover to implement them).
(defun add (a b)
(cond
((and (numberp a) (numberp b))
(+ a b))
((and (numberp a) (zerop a)) b)
((and (numberp b) (zerop b)) a)
(t `(+ ,a ,b))))
(add '(↑27↑ 3 3) '(↑↑↑↑ 3 3))
--> (+ (↑27↑ 3 3) (↑↑↑↑ 3 3))
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.