Commit Graph

80 Commits

Author SHA1 Message Date
Gergely Nagy
fa24042cb0 hy.contrib.walk: Add (macroexpand-all)
This function will recursively perform all possible macroexpansions in
the supplied form. Unfortunately, it also traverses into quasiquoted
parts, where it shouldn't, but it is a useful estimation of macro
expansion anyway.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-02-01 18:34:12 +01:00
Gergely Nagy
817b4688d8 hy.contrib.walk: New contrib module for walking the Hy AST
The hy.contrib.walk module provides a few functions to walk the Hy AST,
and potentially transform it along the way. The main entry point
is (walk), which takes two functions and a form as arguments, and
applies the first (inner) function to each element of the form, building
up a data structure of the same type as the original. Then applies outer
(the second function) to the result.

Two convenience functions are provided: (postwalk) and (prewalk), which
do a depth-first, post/pre-order traversal of the form.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-02-01 18:34:12 +01:00
Nicolas Dandrimont
2094133193 Merge branch 'master' into pr/441 2014-01-17 20:23:49 +01:00
Berker Peksag
25459177eb Move "hy on meth" example to eg/. 2014-01-14 06:03:57 +02:00
Paul Tagliamonte
5a64f18726 Refactor (loop) in terms of fnr; change to use decorator. 2014-01-13 20:37:25 -05:00
Paul Tagliamonte
0afbbeb68c Add (recur) for functions and stuff. 2014-01-12 18:53:08 -05:00
Clinton N. Dreisbach
47d67b0062 Added loop/recur macro for tail-call optimization 2014-01-12 14:02:27 -05:00
Paul Tagliamonte
c0a654e6cb Add callgraph stuff. Slick look. 2014-01-10 21:03:19 -05:00
Nicolas Dandrimont
77baf3b9f3 Merge branch 'meth-fix' of https://github.com/Willyfrog/hy into Willyfrog-meth-fix
Conflicts:
	tests/__init__.py
2014-01-02 00:53:40 +01:00
Paul Tagliamonte
eeef65b505 Change the signature of (for) and (with).
(for) is restored to clojure-like flatness.
 (with) can be used without the nested list if you don't care about the
        name.

   Tests and examples updated.
2013-12-31 13:35:31 -05:00
Foxboron
d82636958b added for and with macros
Fixed up anaphoric.hy and added the tests too native_tests/__init__.py

added __init__.hy
2013-12-29 16:50:21 +01:00
Paul Tagliamonte
9656c7f53c Add profiling macros 2013-12-28 11:25:27 -05:00
Paul Tagliamonte
1dc26148c6 Merge branch 'master' into paultag/ana/if
Conflicts:
	hy/contrib/anaphoric.hy
2013-12-26 17:57:29 -05:00
Abhishek L
c69c14cc7d contrib/anaphoric: More anaphoric macros added
* hy/contrib/anaphoric.hy: The following anaphoric macros have been
  added
  `ap-reject` : Opposite of ap-filter, yields the elements when a `pred`
  evaluates to false
  `ap-dotimes` : Execute body forms (possibly for side-effects) n times
  with `it` bound from 0 to n-1
  `ap-first` : return the first element that passes predicate
  `ap-last`  : return the last element that passes predicate
  `ap-reduce`: anaphoric form of reduce that allows `acc` and `it` to
  create a function that is applied over the list

* docs/contrib/anaphoric.rst: updated docs to reflect these changes

* tests/__init__.py: updated to explicitly include tests for anaphoric
  macros
2013-12-26 05:57:06 +02:00
Paul Tagliamonte
6172b60e75 Add anaphoric if statement 2013-12-25 12:14:26 -05:00
Guillermo Vaya
aeb0cd4c72 Fixed docstring 2013-12-09 11:49:17 +01:00
Guillermo Vaya
f913c2aa8c meth wasn't accepting correctly its parameters
Now also accepts more than 1 statement in the code part of the macro
refactored to use only 1 codebase (no more route != route-with-macros)
2013-12-09 11:48:13 +01:00
agentultra
5753fc0789 Fix typo in ap-map-when 2013-11-30 10:30:42 -05:00
agentultra
77db779019 Fix typo in ap-each 2013-11-30 10:29:41 -05:00
agentultra
cb6889314a Add documentation and doc strings 2013-11-29 19:59:20 -05:00
agentultra
179017b9bd Move anaphoric macros to contrib module 2013-11-28 23:53:02 -05:00
Guillermo Vaya
ff7c71b9c9 comply with hy's tao rules for getattr 2013-09-23 23:34:45 +02:00
Guillermo Vaya
3f1243f88c changed to use short version of macros 2013-09-23 23:34:45 +02:00
Guillermo Vaya
d495473c54 Translation of meth from Python to Hy 2013-09-23 23:34:45 +02:00
Paul Tagliamonte
8717d40e19 Rushed fix for the contrib.meth macros 2013-05-12 13:40:30 -04:00
Julien Danjou
2ef9a0fdaf Rename decorate-with' to with-decorator'
Fixes #158

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-28 17:14:22 +02:00
Paul R. Tagliamonte
e0ed7cac40 Revert "Make HySymbol bytes free!"
This reverts commit 8b144a4f3d.
2013-04-06 20:02:08 -04:00
Julien Danjou
8b144a4f3d Make HySymbol bytes free!
We can know use any amount and type of bytes to build a HyString, meaning we
can use Unicode and UTF-8 for our function and variables.

Eat that, snake!

Signed-off-by: Julien Danjou <julien@danjou.info>
2013-04-06 23:37:34 +02:00
Paul R. Tagliamonte
684c0e928b License bits. 2013-03-28 22:42:53 -04:00
Paul R. Tagliamonte
1f1676c354 Adding in meth 2013-03-27 22:19:27 -04:00