Giter Club home page Giter Club logo

Comments (5)

dubek avatar dubek commented on August 25, 2024

Look at the examples subdir for some, well, examples, like Clojure-like protocols.

For a bunch of more Mal code (like a Mal tokenizer and parser) you can look at my malc repository, though I can't recommend specific reusable functions on top of my head.

@kanaka and I previously discussed adding a lib subdir with core.mal and a bunch of other stuff (even move tokenizer.mal from malc). It hasn't happened (yet).

from mal.

kanaka avatar kanaka commented on August 25, 2024

@ktodyruik yes, please feel free to send pull requests that add useful functions to the examples/ subdir. At some point, we'll re-organize to move more lib/contrib related stuff to a separate directory. If you include a test file in the same directory for now (and using the standard format), that would be great too.

from mal.

kanaka avatar kanaka commented on August 25, 2024

@ktodyruik also a lot of Clojure functions and macros should port to mal fairly easily as long as they don't rely on protocols or lazy sequences. The semantics and data structures in mal are modeled after Clojure.

from mal.

ktodyruik avatar ktodyruik commented on August 25, 2024

@kanaka Could you elaborate on what you meant by "If you include a test file in the same directory for now (and using the standard format), that would be great too." Thanks.

from mal.

kanaka avatar kanaka commented on August 25, 2024

The test syntax I'm referring to is that used in tests/*. And you can run runtest.py directly to run mal tests. For example, consider you defined a sumdown function in examples/sumdown.mal:

(def! sumdown (fn* (N) (if (> N 0) (+ N (sumdown  (- N 1))) 0)))

The you could define a test file test_sumdown.mal like this:

(load-file "sumdown.mal")

(sumdown 0)
;=>0
(sumdown 1)
;=>1
(sumdown 5)
;=>15

You can now run those tests using a specific implementation like this:

mal/examples $ ../runtest.py test_sumdown.mal ../js/run
Started with:
Mal [javascript]

TEST: (load-file "sumdown.mal") -> ['',*] -> SUCCESS
TEST: (sumdown 0) -> ['',0] -> SUCCESS
TEST: (sumdown 1) -> ['',1] -> SUCCESS
TEST: (sumdown 5) -> ['',15] -> SUCCESS

TEST RESULTS (for test_sumdown.mal):
    0: soft failing tests
    0: failing tests
    4: passing tests
    4: total tests

from mal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.