| Deutsch English Français Italiano |
|
<Python-20250412150133@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.lisp
Subject: Writing HG LISP in Python, kind of
Date: 12 Apr 2025 14:04:02 GMT
Organization: Stefan Ram
Lines: 68
Expires: 1 Mar 2026 11:59:58 GMT
Message-ID: <Python-20250412150133@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de R5OMg7SlwH5J2c75vKs2aw3AnxD79KAz0TByHI59AchZpp
Cancel-Lock: sha1:h9SaS6y2cKLQDeldbwVIySQCNQQ= sha256:egJfODvQjZDEQS0TvJbYLrSFrrwXpD6tCkrAjLwgaro=
X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Bytes: 3042
From my recent postings in other newsgroups: The precending
generator rewritten in Python in a style that tries to
imitate LISP with the means of Python.
CADD = lambda Z1, Z2: [
Z1[0] + Z2[0],
Z1[1] + Z2[1]
]
CMUL = lambda Z1, Z2: [
(Z1[0] * Z2[0]) - (Z1[1] * Z2[1]),
(Z1[0] * Z2[1]) + (Z1[1] * Z2[0])
]
CABS = lambda Z: (
((Z[0] ** 2) + (Z[1] ** 2)) ** 0.5
)
MANDELBROT = lambda X, Y: (
(lambda C, Z, A: (
(lambda ITERATE: ITERATE(C, Z, A, ITERATE))(
lambda C, Z, A, ITERATE: (
126 - C if C < 32 or CABS(Z) > 2 else (
(lambda TEMP_CMUL, TEMP_CADD: (
ITERATE(
C - 1,
TEMP_CADD,
A,
ITERATE
)
))(
CMUL(Z, Z),
CADD(A, CMUL(Z, Z))
)
)
)
)
))(126, [X, Y], [X, Y])
)
GENERATE_MANDELBROT = lambda: (
(lambda LOOP_Y: LOOP_Y(-1, LOOP_Y))(
lambda Y, LOOP_Y: None if Y > 1.1 else (
(lambda LOOP_X: LOOP_X(-2, LOOP_X))(
lambda X, LOOP_X: None if X > 1 else (
(lambda CHAR_CODE: (
print(" " if CHAR_CODE < 50 else "*",end=''),
LOOP_X(X + 0.04, LOOP_X)
))(
MANDELBROT(X, Y)
)
)
),
print(),
LOOP_Y(Y + 0.1, LOOP_Y)
)
)
)
GENERATE_MANDELBROT()