Created
March 23, 2015 14:03
-
-
Save jonelf/c5adac26bba63c376b0a to your computer and use it in GitHub Desktop.
Mandelbrot in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for line in 0...32 { | |
println("".join((0...78).map { (col: Int) -> String in | |
var x = 0.0, y = x, i = 0 | |
do { | |
x = x * x - y * y + Double(col) / 20.0 - 2.3 | |
y = 2 * x * y + Double(line) / 10.0 - 1.5 | |
i++ | |
} while (x * x + y * y) < 4 && i < 78 | |
return "\(UnicodeScalar(0x1f35b + i))" | |
}) | |
) | |
} |
Author
jonelf
commented
Feb 15, 2024
Open a big macOS terminal and run
echo 'for l in 0...42{print((0...65).map{(col: Int)->String in var x=0.0,y=x,i=0;repeat{x=x*x-y*y+Double(col)/20.0-2.1;y=2*x*y+Double(l)/13.0-1.5;i=i+1}while(x*x+y*y)<4&&i<78;return String(UnicodeScalar(i+0x1f35b)!)}.joined(separator:""))}'|swift
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment