Comments (3)
I think you have a couple of typos. You test function is missing some parens:
(def! test (fn* [l m n] (l m n)))
And your fls function has an incorrect variable name:
(def! fls (fn* [t f] f))
Making those changes I get the correct behavior.
from mal.
Ninja edited my typo up above, that wasn't the issue. It seems ()
around multiple variables gives me the correct behaviour. Is that Lispful that I need ()
around multiple variables? For what it's worth Haskell doesn't need them though that may be no indication. let test = (\l -> \m -> \n -> l m n)
from mal.
Parens in Lisp define lists. However, when an unquoted list is evaluated in Lisp, the first position in the list is a function and the rest of the elements are arguments. So (+ 2 3)
means call the +
function using the arguments 2 and 3. In mal, (fn* (a b) (+ a b))
means define an anonymous function that takes two arguments and calls +
using those arguments. This (fn* (a b) + a b)
is quite different. That's an anonymous function containing three elements that are not in a list. Mal only uses the first element in the function body so it's really equivalent to this: (fn* (a b) +)
. When you invoke/apply that function you'll just get what +
evaluates to. In other words, this ( (fn* (a b) +) 7 8)
will invoke/apply the anonymous function, the +
symbol will be evaluated to the native function for addition which will be returned.
It's late at night and I'm tired, so the above explanation might be a bit rambling, let me know if it doesn't make sense and I'll try and give a better answer tomorrow after some sleep.
from mal.
Related Issues (20)
- VHDL: defmacro! doesn't modify existing functions HOT 1
- make "test^js^step0" fails -- Fatal error in , line 0 -- Check failed: result.second. HOT 1
- 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
- How is `cond` supposed to work? HOT 2
- 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
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.