Benoit B Mandelbrot 的名字

11 views
Skip to first unread message

Atommann

unread,
Oct 14, 2015, 11:30:23 PM10/14/15
to Shenzhen DIY Lab
Hi,

我们在 IRC 里讨论用 vertical plotter 在墙上画 Mandelbrot set, Mitch 问我:“你知道
Benoit B Mandelbrot 名字中间 middle name 是什么意思吗?”

实在想不出来。原来 B 是 Mandelbrot 自己取的 middle name,它就表示 Benoit B
Mandelbrot。因此,Mitch 认为他应该立即写个代码来打印这个递归的,自相似的名字。原话:"Man, I should
really write a computer program to do this..."

我则认为,这种代码,天然应该用 lisp 语言来写。

下面的代码由 xyh 给出:

#! /usr/bin/guile -s
!#

(define bbm
(lambda (n)
(cond [(= n 0)
'(Benoit B Mandelbrot)]
[else
`(Benoit ,(bbm (- n 1)) Mandelbrot)])))

(display (bbm 2))
(newline)

ref
https://en.wikipedia.org/wiki/Benoit_Mandelbrot

--
Best regards,
Atommann

Atommann

unread,
Oct 15, 2015, 12:18:26 AM10/15/15
to Shenzhen DIY Lab
#! /usr/bin/guile \
-e main -s
!#

(define (bbm n)
(cond [(= n 0) '(Benoit B Mandelbrot)]
[else (list 'Benoit (bbm (- n 1)) 'Mandelbrot)]))


(define (main args)
(display (bbm (string->number (cadr args))))
(newline))

新版本,可以传参数 (谢谢 Nala 和 xyh 的指导)。

# chmod a+x bbm.scm
# .bbm.scm 2

--
Best regards,
Atommann

Mitch Davis

unread,
Oct 15, 2015, 12:57:05 AM10/15/15
to sz...@googlegroups.com
Hello my hackinfriends,

2015-10-15 14:30 GMT+11:00 Atommann <atom...@gmail.com>:
Hi,

我们在 IRC 里讨论用 vertical plotter 在墙上画 Mandelbrot set, Mitch 问我:“你知道
Benoit B Mandelbrot 名字中间 middle name 是什么意思吗?”

Benoit gave himself a self-similar name.

  https://en.wikipedia.org/wiki/Self-similarity

xyh, thanks for your Scheme program.  Here's mine in awk:

[mjd@xiaomao tmp]$ cat bbm.awk
#! /bin/awk -f

function bbm(n)
{
    return "Benoit " (n == 0 ? "B" : bbm(n - 1)) " Mandelbrot";
}

BEGIN {
    print bbm(2);
    exit(0);
}
[mjd@xiaomao tmp]$ ./bbm.awk
Benoit Benoit Benoit B Mandelbrot Mandelbrot Mandelbrot
[mjd@xiaomao tmp]$  


And one in Python (non-recursive):

[mjd@xiaomao tmp]$ python
Python 2.7.5 (default, Apr 10 2015, 08:09:05)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def bbn(n):
...     print "".join(("Benoit " * (n + 1), "B", " Mandelbrot" * (n + 1)))
...
>>> bbn(2)
Benoit Benoit Benoit B Mandelbrot Mandelbrot Mandelbrot
>>>
[mjd@xiaomao tmp]$


Mitch.

李方舟

unread,
Oct 15, 2015, 2:18:39 AM10/15/15
to Shenzhen DIY community
我原来写的 python 代码:
#***************************************************************
from PIL import Image
import math

class Coordinate():
  '''class Coordinate by Rafael'''
  x = None
  y = None
  def __init__(self,content):
    # try:
      Coordinate.x=content[0]/1+150
      Coordinate.y=content[1]/1+150
    # except:
      # print (r'class Coordinate except')
      # raise myException

def main():
  lut=[] # look up table
  for i in range (256):
    i0=math.sqrt(float(i))*16
    i0=int(i0)
    if i0>255:
      i0=255
    lut.append(i0)
  print('len(lut) = ',len(lut))
  coor0 = Coordinate((150,150))
  im0 = Image.new("RGBA",(300,300))

  fw=open(r'mandelbrot.txt','w')
  cntAll = 0
  for j in range (-150,150,1):
    for i in range (-150,150,1):
      coor0 = Coordinate((i,j))
      cntAll = cntAll +1
      cnt = 0
      arg = 0.0+0.0j
      arg = 0
      c = complex(float(i)/100,float(j)/100)
      while arg.real <10 and cnt <256:
        arg = arg*arg+c
        cnt = cnt + 1
      im0.putpixel((coor0.x,coor0.y),(lut[cnt-1],lut[cnt-1],lut[cnt-1],255))
    fw.write('\n')
  print(cntAll)
  im0.save(r'mandelbrot.png')
  print(time.clock())

# print(dir())
os.chdir(str(os.path.split(os.path.realpath(__file__))[0]))
if __name__ == '__main__':
  main()
#***************************************************************

在 2015年10月15日星期四 UTC+8上午11:30:23,atommann写道:

Nala Ginrut

unread,
Oct 15, 2015, 2:45:51 AM10/15/15
to sz...@googlegroups.com
So cool Mitch! I love the AWK one!

@xyh 年轻人Scheme不是这样用的:

=========================guile code============================
(use-module (srfi srfi-1))
(define (bbm n)
(fold (lambda (_ p) `(Benoit ,p Mandelbrot)) 'B (iota n)))
============================end================================


(bbm 3)
==> (Benoit (Benoit (Benoit B Mandelbrot) Mandelbrot) Mandelbrot)
> --


Mitch Davis

unread,
Oct 15, 2015, 6:16:54 AM10/15/15
to sz...@googlegroups.com
On Thu, Oct 15, 2015 at 5:45 PM, Nala Ginrut <nalag...@gmail.com> wrote:

(define (bbm n)
 (fold (lambda (_ p) `(Benoit ,p Mandelbrot)) 'B (iota n)))
(bbm 3)

==> (Benoit (Benoit (Benoit B Mandelbrot) Mandelbrot) Mandelbrot)

What if Benoit was a function?

Mitch.

Nala Ginrut

unread,
Oct 15, 2015, 6:43:23 AM10/15/15
to sz...@googlegroups.com
Interesting!
(define (Benoit x y) (format #t "~a ~a~%" x y))
(define B 'B)
(define Mandelbrot 'Mandelbrot)

(primitive-eval (bbm 3))

Anyway, you need to define these three symbols. So it could be anything
depends on your design. ;-)
> --


颜民革

unread,
Oct 15, 2015, 9:33:21 PM10/15/15
to sz...@googlegroups.com
歪楼了。。。



来自 魅族 MX4



-------- 原始邮件 --------
发件人:李方舟 <rafael...@gmail.com>
时间:周四 10月15日 14:18
收件人:Shenzhen DIY community <sz...@googlegroups.com>
主题:[szdiy] Re: Benoit B Mandelbrot 的名字

我原来写的 python 代码:
#***************************************************************
Hi,

我们在 IRC 里讨论用 vertical plotter 在墙上画 Mandelbrot set, Mitch 问我:“你知道
Benoit B Mandelbrot 名字中间 middle name 是什么意思吗?”

实在想不出来。原来 B 是 Mandelbrot 自己取的 middle name,它就表示 Benoit B
Mandelbrot。因此,Mitch 认为他应该立即写个代码来打印这个递归的,自相似的名字。原话:"Man, I should
really write a computer program to do this..."

我则认为,这种代码,天然应该用 lisp 语言来写。

下面的代码由 xyh 给出:

#! /usr/bin/guile -s
!#

(define bbm
  (lambda (n)
    (cond [(= n 0)
       '(Benoit B Mandelbrot)]
      [else
       `(Benoit ,(bbm (- n 1)) Mandelbrot)])))

(display (bbm 2))
(newline)

ref
https://en.wikipedia.org/wiki/Benoit_Mandelbrot

--
Best regards,
Atommann

--
--
You received this message because you are subscribed to the Google
Groups "Shenzhen DIY community" group.
To post to this group, send email to sz...@googlegroups.com
To unsubscribe from this group, send email to
szdiy+un...@googlegroups.com
For more options, visit this group at
http://www.szdiy.org
http://groups.google.com/group/szdiy?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛上的“Shenzhen DIY community”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到szdiy+un...@googlegroups.com
要查看更多选项,请访问https://groups.google.com/d/optout
Reply all
Reply to author
Forward
0 new messages