Skip to content

Instantly share code, notes, and snippets.

@jonelf
Created March 23, 2015 14:03
Show Gist options
  • Save jonelf/c5adac26bba63c376b0a to your computer and use it in GitHub Desktop.
Save jonelf/c5adac26bba63c376b0a to your computer and use it in GitHub Desktop.
Mandelbrot in Swift
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))"
})
)
}
@jonelf
Copy link
Author

jonelf commented Feb 15, 2024

image

@jonelf
Copy link
Author

jonelf commented Feb 16, 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