Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197085
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Paul Rubin <no.email@nospam.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Lengthy numbers |
| Date | Mon, 23 Dec 2024 15:38:13 -0800 |
| Organization | A noiseless patient Spider |
| Lines | 16 |
| Message-ID | <871pxy9di2.fsf@nightsong.com> (permalink) |
| References | <eXx9P.64901$o72.28550@fx01.ams4> <mailman.14.1734910364.2912.python-list@python.org> <extend-20241223090009@ram.dialup.fu-berlin.de> |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Date | Tue, 24 Dec 2024 00:38:19 +0100 (CET) |
| Injection-Info | dont-email.me; posting-host="0ec77f02b40872df5202021528adc871"; logging-data="1527689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/U6NkNhLK5pY12iw9v4n4s" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
| Cancel-Lock | sha1:ai7ePeHug8IL6mwyca7VcFgb/Ic= sha1:wUf/NMpJBjlSYOkk5Bodv+ZKxuE= |
| Xref | csiph.com comp.lang.python:197085 |
Show key headers only | View raw
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> So in theory, this would crank out an infinite list that looks like
> [0, 0, 0, 0, ...]. In the real world, though, if you try to print or
> use this list, your program will probably freeze up faster than the
> 405 at rush hour.
The freeze-up happens as soon as you create the list. Unfortunately
iterators don't have anything like .extend so I don't see a way to
create recursive ones like that, short of writing more verbose code
using yield. In Haskell it is straightforward:
fibonacci = 0 : 1 : zipWith (+) (tail fibonacci)
main = print (take 10 fibonacci)
should print [0,1,1,2,3,5,8,13,21,34].
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
Lengthy numbers Gilmeh Serda <gilmeh.serda@nothing.here.invalid> - 2024-12-21 11:49 +0000
Re: Lengthy numbers (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-12-21 21:03 +0000
Re: Lengthy numbers (Posting On Python-List Prohibited) Gilmeh Serda <gilmeh.serda@nothing.here.invalid> - 2024-12-22 09:18 +0000
Re: Lengthy numbers (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-12-23 23:06 +0000
Re: Lengthy numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2024-12-22 23:32 +0000
Re: Lengthy numbers Paul Rubin <no.email@nospam.invalid> - 2024-12-23 15:03 -0800
Re: Lengthy numbers Paul Rubin <no.email@nospam.invalid> - 2024-12-23 15:38 -0800
csiph-web