Symphony: A Poetic JavaScript Code
Last Updated: 2025-04-25 | Tags: JavaScript, Programming, Poetry
A Poetic JavaScript Code I Found Somewhere, Thanks For The Poet Unknown !
class Symphony {
constructor() {
this.memo = new Map([
[0, 0],
[1, 1]
])
}
*fibonacci(limit = Infinity, a = 0, b = 1) {
while (limit--) (yield a, ([a, b] = [b, a + b]))
}
graceful(n) {
return this.memo.has(n) ? this.memo.get(n) : (this.memo.set(n, this.graceful(n - 1) + this.graceful(n - 2)), this.memo.get(n))
}
}
const poetry = new Symphony()
console.log([...poetry.fibonacci(10)].map((n) => n.toString().padStart(3, ' ')).join(' → '))