Brilliant, I like classic lisp function names.
Great stuff.
Prof. Victor Lazzarini
Maynooth University
Ireland
Warning
This email originated from outside of Maynooth University’s Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
Yes, the list operations are there under the Clojure names first and rest. You can give them the familiar names with two definitions:
(def car first)
(def cdr rest)(car '(10 20 30)) ; => 10
(cdr '(10 20 30)) ; => (20 30)In traditional Lisp, car and cdr access the two parts of a cons cell. Clojure uses a sequence interface: first gives the first item, and rest gives the remaining items, across collections such as lists and vectors. Common Lisp also has first and rest, so the names themselves aren’t unique to Clojure.
Functions are values here, so those definitions simply give the existing functions another name. Neither operation changes the original collection.
Here is a recursive Fibonacci example using car and cdr, with this implementation’s syntax:
(defn fib-step [n pair]
(if (= n 0)
(car pair)
(fib-step (- n 1)
(list (car (cdr pair))
(+ (car pair) (car (cdr pair)))))))(defn fib [n]
(fib-step n '(0 1)))(fib 10) ; => 55
The two-item list holds consecutive Fibonacci numbers. Each call advances it from (a b) to (b (+ a b)), until n reaches zero.
Perhaps you could submit a PR to add a news entry to the new csound.com site?
Hi all,
Following my presentation at ICSC, I’ve released Make A Lisp for Csound 0.3.0. You can now try this Clojure-style Lisp, written in Csound 7, through two Web IDE projects:
Make A Lisp Showcase
https://ide.csound.com/editor/CaGowm3UM0jY3THb1Ol9Ten short, commented lessons covering values, collections, functions, immutable data, atoms, and macros. Press Play and follow the output in the Console.
Interactive Lisp Repl
https://ide.csound.com/editor/nzI9QU6wheOzfbFRusbNPress Play, then type Lisp at the lisp> prompt in the Console. Try (+ 2 3), define a function, or experiment with an atom. Definitions stay between inputs. The REPL uses Csound’s readline opcode.
Both projects include the interpreter and a README, and run in the browser.
Source and 0.3.0 release:
https://github.com/hlolli/csound-make-a-lisp/releases/tag/v0.3.0Please give them a try. Feedback and bug reports are welcome!
Best,
Hlöðver
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted hereCsound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
The information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.
Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.
Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig dataprotection@mu.ie agus scrios an ríomhphost seo ó do chóras.
Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.
Registered charity number 20037130
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here