emojicode / emojicode

😀😜🔂 World’s only programming language that’s bursting with emojis

Home Page:https://emojicode.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recursion

Shakedp opened this issue · comments

⭐️ Proposed change

Maybe it exists already, but I didn't find a way to use it - I need to write a recursive function but Ican't reference its name from within the function - doesn't compile.

🕺 Example

Ackermann function:

🍇 m🔢 n🔢 ➡️ 🔢
😀 🔤ackermann(🧲m🧲,🧲n🧲)🔤 ❗️
↪️ m 🙌 0 🍇
↩️ n ➕ 1
🍉
🙅↪️ n 🙌 0 🍇
⁉️ ackermann m ➖ 1 1❗️➡️ result
↩️ result
🍉
🙅 🍇
⁉️ ackermann m n ➖ 1 ❗️➡️ result1
⁉️ ackermann m ➖ 1 result1 ❗️➡️ result
↩️ result
🍉
🍉 ➡️ ackerman

Fails to compile:
file2.🍇:24:8: 🚨 error: Variable "ackerman" not defined.
⁉️ ackerman m ➖ 1 1❗️➡️ result
⬆️

commented

Write a method to easily achieve this.

(You can do this with callables but you would need to declare the variable as optional first, then assign the closure to the variable and obviously unwrap the accesses to your closure variable.)