Commit Graph

255 Commits

Author SHA1 Message Date
Berker Peksag
3528cc8278 Kill kwapply.
Closes #433.
2014-04-09 20:10:31 +03:00
Paul Tagliamonte
54da3f08dd Add Curry module. 2014-03-29 14:40:13 -04:00
Berker Peksag
6829d6fb3a Tweak the zipwith doc a bit and add @kirbyfan64 to AUTHORS. 2014-02-22 02:21:34 +02:00
kirbyfan64
d282d65cde Add zipwith 2014-02-22 02:14:27 +02:00
James King
b97e0258e1 Fix for #497
One would expect the form:

    > (defmacro a (&rest b) b)
    > (a 1 2)

To return a tuple object but we have no Hy model so it returns a HyList.
Not sure if this is the right thing to do.
2014-02-19 00:09:37 -05:00
Paul Tagliamonte
e219973853 Fix up quoting keywords.
Fixes this:

=> :foo
'\ufdd0:foo'
=> `:foo
'\ufdd0\ufdd0:foo'
2014-02-17 18:00:31 -05:00
Paul Tagliamonte
2f751df0f6 Merge branch 'master' into pr/489 2014-02-15 11:49:12 -05:00
han semaj
24a1567b00 Implement every? and some 2014-02-11 21:42:56 +13:00
Foxboron
66366b5bc9 Added defmulti 2014-02-05 16:07:48 +01:00
Gergely Nagy
e8dfe5bfb2
hy.contrib.walk: Add support for walking cons cells
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-02-01 18:36:57 +01:00
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
Abhishek L
4b54e3c748 Merge master onto pr/471
Conflicts:
	hy/core/language.hy
2014-01-30 21:50:23 +05:30
James King
cbb8cc1d37 Add integer-char? to core 2014-01-28 17:28:41 -05:00
Nicolas Dandrimont
52144820ca Add a cons object and related mechanisms
Closes: #183
2014-01-23 23:08:52 +01:00
Nicolas Dandrimont
fad67bd8f5 Merge branch 'master' into pr/468 2014-01-23 22:14:23 +01:00
Nicolas Dandrimont
b99af411c8 Merge branch 'master' into pr/461
Conflicts:
	tests/native_tests/native_macros.hy
2014-01-23 21:57:17 +01:00
Abhishek L
10f1f24a18 Adding a simple `identity' function
* hy/core/language.hy: Adding a simple `identity` function that returns
  the argument supplied to it

* docs/language/core.rst: Updated docs with identity function
2014-01-22 00:56:28 +05:30
Gergely Nagy
e90b24b73a
hy/core/macros.hy: Add an (if-not) macro
Sometimes it is better to start with the false condition, sometimes that
makes the code clearer. For that, the (if-not) macro, which simply
reverses the order of the condition blocks, can be of great use.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2014-01-18 22:56:20 +01:00
Gergely Nagy
21709f0199 hy/core/macros.hy: Add defn-alias / defun-alias
In the same vein as defmacro-alias, this implements defn-alias /
defun-alias, which does essentially the same thing as defmacro-alias,
but for functions.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
2014-01-18 16:09:35 +01:00
Nicolas Dandrimont
3286271cb8 Merge branch 'master' into pr/454 2014-01-17 20:32:50 +01:00
Berker Peksag
db9b9c6876 Move all contrib.meth tests to tests/native_tests/contrib/. 2014-01-17 03:56:12 +02:00
Foxboron
a35ecc41bd Fix reader macros to actually be macros 2014-01-17 01:07:47 +01:00
Nicolas Dandrimont
8bfa4f33fc Add set comprehensions, dict comprehensions and generator expressions
Closes: #14 (woo, two-digit tickets)
2014-01-16 00:49:48 +01:00
Clinton N. Dreisbach
47d67b0062 Added loop/recur macro for tail-call optimization 2014-01-12 14:02:27 -05:00
Abhishek L
f159f1499b Adding a simple coll? function to the core
* hy/core/language.hy:
  -Added a simple coll? function that checks whether the given argument
  is an iterable and not a string,
  - Also replaced the check in `flatten` by coll?

* tests/native_tests/core.hy: Tests updated for checking coll?
2014-01-12 15:49:09 +05:30
Paul Tagliamonte
110476901c Fix a few typos in the tests. Thanks again, @olasd 2014-01-10 22:31:00 -05:00
Paul Tagliamonte
0f74b1ddf3 Add handling for (for []). Nice catch, @olasd. 2014-01-10 22:29:20 -05:00
Paul Tagliamonte
abd0669911 add test for new for logic. 2014-01-10 22:16:35 -05:00
Nicolas Dandrimont
78f6301e27 Add tests for the attribute access DSL 2014-01-09 03:35:32 +01:00
Nicolas Dandrimont
d3fa1fd1a8 Add disassemble function to hy.core.language
This function dumps the AST or the python code generated by evaluating a quoted expression to stdout.

Fixes #58
2014-01-04 03:47:04 +01:00
Nicolas Dandrimont
2f7d40b409 Factor the calling-module-name function 2014-01-03 21:41:14 +01:00
Nicolas Dandrimont
74739bc43e Whitespace fix 2014-01-02 00:52:29 +01:00
Nicolas Dandrimont
88451bbeaa Merge branch 'better-macroexpand' of https://github.com/sbp/hy into sbp-better-macroexpand
Conflicts:
	hy/core/language.hy
	tests/native_tests/language.hy
2014-01-02 00:49:40 +01:00
Bob Tolbert
032200bcb4 Some small doc fixes
This cleans up a number of doc warnings, including a bad
underline for zero?

While there, added a nil? function to match up with the
new nil is None.

Also un-hid myself from coreteam.
2013-12-31 16:14:05 -07: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
Paul Tagliamonte
e754a58237 Merge branch 'master' into pr/363 2013-12-31 11:41:30 -05:00
Abhishek L
0a80b87b7f Merge branch 'master' onto pr/395 2013-12-31 03:37:26 +05:30
Gergely Nagy
62522a5f86 Allow get with multiple arguments
When calling get with more than two arguments, treat the rest as indexes
into the expression from the former. That is, (get foo "bar" "baz")
would translate to foo["bar"]["baz"], and so on.

This fixes #362.

Requested-by: Sean B. Palmer <sean@miscoranda.com>
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-12-30 12:04:40 +01: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
Bob Tolbert
55a7ab1667 add nil as synonym for None 2013-12-27 13:50:19 -07:00
Bob Tolbert
b2bb161cb0 Merge pull request #391 from olasd/bugfix/apply-method-call
Fix apply with method calls
2013-12-27 11:46:59 -08: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
Nicolas Dandrimont
cfbc792957 Fix apply with method calls
Apply didn't work on method calls (i.e. `(apply .foo [bar]) broke).
This slipped through because there were no tests of this behavior. I noticed
it while trying to merge the `meth` fixes.
2013-12-23 21:02:45 +01:00
Foxboron
c9fdd40c9f Hy reader macros #377
Added first iteration of reader macros
Refactored defmacro and defreader
Added test inn hy/tests/lex/test_lex.py
Added new test in hy/tests/native/tests
Added new test in hy/tests/macros.

changed the error given in the dispatch macro and added some handling for missing symbol and invalid characters
2013-12-23 14:33:51 +01:00
Nicolas Dandrimont
1a701d4dc4 Whitespace fix 2013-12-22 20:04:12 +01:00
Nicolas Dandrimont
ec2b5fb7ad Merge branch 'kwapply-macro' of https://github.com/Willyfrog/hy into Willyfrog-kwapply-macro
Conflicts:
	hy/core/language.hy
	hy/core/macros.hy
	tests/native_tests/language.hy
2013-12-22 20:03:00 +01:00
Nicolas Dandrimont
ceb612f385 Merge branch 'fix/arith-identity' of https://github.com/theanalyst/hy into theanalyst-fix/arith-identity 2013-12-22 19:32:10 +01:00