Comments (2)
Well, I wrote one from scratch that words for me and expands correctly
- just not variadic which I don't much care for anyway;
- minor idiosyncrasies: my MAL doesn't have
defmacro
, onlydef
, and my false/true/nil are:keyword
s
(def caseOf
(macro (cases)
(if (isEmpty cases)
:nil
(let ( (this_case (nth cases 0))
(case_cond (nth this_case 0))
(case_then (nth this_case 1)))
`(if ~case_cond
~case_then
(caseOf ~(rest cases)))))))
Seems to work well:
เฟ (macroExpand (caseOf [ [:false (do (print :nay) :nope)] [:true (do (print :yay) (+ 1 2))] ]))
(if :false (do (print :nay) :nope) (caseOf ([:true (do (print :yay) (+ 1 2))])))
เฟ (caseOf [ [:false (do (print :nay) :nope)] [:true (do (print :yay) (+ 1 2))] ])
:yay3
Anyone see any issues with that? Also, still eager to learn what I was missing about MAL's own cond
! Surely it isn't actually butchered and just looked that way to under-informed me (and my MAL impl).
from mal.
Update: only now noticed that MAL's if
has the 3rd arg as optional, missed that part before. Still, having updated my MAL impl to use :nil
for a missing 3rd if
arg, the cond
as originally formulated:
(def cond
(macro (& xs)
(if (> (count xs) 0)
(list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
still results in a stack overflow with 2 args or more ๐ตโ๐ซ my own caseOf
formulation works though and as before, all other tests pass ยฏ\_(ใ)_/ยฏ
from mal.
Related Issues (20)
- PDFs?
- Somebody should solve Rosetta Code challenges with mal
- Mal in Coq? HOT 2
- Apparently in step 3 'env' is a class or structure type, not an object HOT 2
- Questions on different design from lisp: Mal symbol do not use property lists? HOT 1
- Lots of unanswered merge requests HOT 1
- Why is quasiquote so complicated? HOT 3
- What with `` gensym '' HOT 2
- lexicial versus dynamic HOT 1
- Floats don't work in the python implementation. HOT 2
- Is #mal IRC channel still active? people seems tends to use discord now XD HOT 1
- Should `eval` use the top-level environment? HOT 1
- Remaining impls to combine eval-ast/macroexpand into eval HOT 10
- common-lisp fails to build HOT 1
- Fix self-hosted test failures HOT 30
- Vala in self-hosted mode (i.e. running mal) has rare memory corruption (probably in throw/try/catch) HOT 1
- Fix powershell and elisp predicate/equality issues revealed by #665 HOT 1
- latex3 time-ms seems to be overflowing now HOT 2
- vbs: Ubuntu install of python2 in WSL is failing in CI HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mal.