

The largest n-tuple in Lisp - CaiGengYang

The following expression defines a function called double which returns twice its argument:<p>CL-USER 17 : 8 &gt; (defun double (x) (* x 2)) 
DOUBLE<p>Having fed this to Lisp, we can call double in other functions, or from the top level:<p>CL-USER 18 : 8 &gt; (double 1) 
2<p>CL-USER 18 : 8 &gt; (double 2) 
4<p>CL-USER 18 : 8 &gt; (double 4) 
8<p>I experimented and realised that this works with triple too :<p>CL-USER 21 : 8 &gt; (defun triple (x) (* x 3)) 
TRIPLE<p>CL-USER 22 : 8 &gt; (triple 3) 
9<p>CL-USER 23 : 8 &gt; (triple 6) 
18<p>CL-USER 24 : 8 &gt; (triple 1) 
3<p>This works for quadruple too: I can define a function called quadruple which returns four times its argument :<p>CL-USER 25 : 8 &gt; (defun quadruple (x) (* x 4)) 
QUADRUPLE<p>CL-USER 26 : 8 &gt; (quadruple 4) 
16<p>CL-USER 27 : 8 &gt; (quadruple 8) 
32<p>CL-USER 28 : 8 &gt; (quadruple 16) 
64<p>Works for quintuple too ! :<p>CL-USER 9 : 2 &gt; (defun quintuple (x) (* x 5)) 
QUINTUPLE<p>CL-USER 10 : 2 &gt; (quintuple 4) 
20<p>CL-USER 11 : 2 &gt; (quintuple 5) 
25<p>I then tried a far larger n-tuple : centuple and it works as well !<p>CL-USER 12 : 2 &gt; (defun centuple (x) (* x 100)) 
CENTUPLE<p>CL-USER 13 : 2 &gt; (centuple 6) 
600<p>CL-USER 14 : 2 &gt; (centuple 8) 
800<p>Later on, I realised that there is no limit and you can in fact define n-tuples even up to sextillion in Lisp!
======
bbcbasic
I am not familiar with Lisp but these don't look like n-tuples to me. Is it
just a function that multiplies a value by a fixed number?

As I understand it, a tuple is a collection of typed objects. E.g. in C# the
type Tuple<Int,Bool> or Haskell (Int,Bool)

~~~
CaiGengYang
Yup, It is just a function that multiplies a value by a fixed number.

I just named it n-tuple because it rhymes : quadruple, centuple, but perhaps
it was the wrong way to name it.

I was just surprised to realise that there is no limit to the value of n for
this type of function that multiplies a value by a fixed number, so I put this
on Hackernews.

It was a surprising result, at least to me ...

~~~
bbcbasic
Same in Haskell there is Int for your normal bounded integer (28 bit I think)
and there is Integer which is bounded only by the amount of memory you can
allocate on the heap.

