قلب
Jump to navigation
Jump to search
قلب is a programming language by Ramsey Nasser. The name means Heart and is a recursive acronym for قلب: لغة برمجة meaning Heart: A Programming Language. Acronyms in Arabic are uncommon and difficult to pull off, and the author states that this is the first recursive one he has seen. It was created as an art installation.
Examples
Look on the right side of the page.
Hello world
(قول "مرحبا يا عالم!")
Fibonacci (fybunatshi.qlb)
(حدد فيبوناتشي (لامدا (ن) (إذا (أصغر؟ ن ٢) ن (جمع (فيبوناتشي (طرح ن ١)) (فيبوناتشي (طرح ن ٢)))))) (قول (فيبوناتشي ١٠))
Truth-machine (حق)
( حــدد حق ( لامدا ( علي ) ( قــــــــــــول علي ) ( إذا ( يســـاوي؟ علي ١) ( حـــــــــق علي ))))
Call with either (حق ٠)
or (حق ١)
.
Collatz sequence
Function named (possibly incorrectly) الكولاتز. Plays with creative code layout, which appears to be a feature of this language.
(حدد الكولاتز (لامـدا(ن) (قــــــــــول ن) (إذا (يساوي؟ ١ ن) ( ن) ((حدد نــــصف (قسم ن ٢)) (إذا (يساوي؟ نـصف (أرض نـصف)) (الكولاتــز نـصف) (الكولاتــز (جمع ١ (ضرب ن ٣))))))))
Example use: (الكولاتز ٢٥)
External resources
- Article about the language (from the Wayback Machine; retrieved on 23 October 2018)
- Author's website
Implementation
- https://github.com/nasser/--- (also contains game of life example)
- http://qlb-repl.herokuapp.com/ (live REPL)