Commit graph

31 commits

Author SHA1 Message Date
Linus Björnstam
a47d6d992b fix folding, add :continue
Fix foldig to be an :acc version of in.

:continue will stop the subloop and start the next iteration of the
outer loop
2023-10-30 21:56:54 +01:00
Linus
5381bf5f69 Addendum simplified install
Forgot to change a path.
2022-03-06 21:17:38 +01:00
Linus
f5a3629b56 Make let-kw-form more portable to other syntax-case schemes
* goof.scm (let-kw-form): don't use guile-specific with-ellipsis.
2021-09-25 21:27:50 +02:00
Linus
050f88d678 Fixed misnamed export
* goof.scm: in-vector-reverse and in-string-reverse now properly
exported.
2021-09-25 21:21:29 +02:00
Linus
832c414260 Changes for the better
* goof-impl.scm (loop/first loop/last): add ability to specify a
:default value. Added auxiliary syntax :default.
 * goof/iterators.scm (accumulating hash(q|v)ing): changed auxiliary
keyword from initial -> :initial.
 * goof.scm: export extra keywords
 * doc.html
 * doc.xml : document changes. fix bugs.
2021-08-17 21:36:13 +02:00
Linus
2c323be362 Big change: lexical scoping
This introduces lexical scoping of for clauses. See README.md
2021-05-18 18:12:01 +02:00
Linus
769553832b Start of something big
This marks a deviation from the foof-loop inheritance, and a path
towards a more lexical scope. :for clauses are now bound to the top of
each loop, and the following :bind, :when, :unless, :break, :final and
:acc clauses now follow a the lexical order of when they were
introduced... At least, that's the plan. This commit makes :for, :bind,
:when, :unless and :break work. The rest is broken.

and :let+:let* are no more.
2021-05-16 20:13:55 +02:00
Linus
6f0c6e636f Fixed error reporting of missing :for clause 2021-05-11 10:00:46 +02:00
Linus
a38170a25b Added stop-after and stop-before
These are equivalent to their racket for loop counterparts, and creates
an iterator that signals exhaustion befor or after yielding a value
where a predicate returns true. Not useful in non-nested loops, but
could be useful in inner loops where you want to exit to an outerloop
instead of :break-ing.

Also fixed some bugs in other generator clauses.
2021-05-11 09:48:21 +02:00
Linus
3908019bbc Added some tests.
Fixed some things I noticed when testing the tests.
2021-03-22 19:30:09 +01:00
Linus
5847bd21d4 Fixed :final and make to, by => :to :by
I had a bug. I had an inconsistency. Don't worry. All is fixed.
2021-03-18 12:41:39 +01:00
Linus
bb0de3e949 Added some generator clauses
Now in-file, in-port, in-lists and in-generator have generator clauses
2021-02-18 22:08:34 +01:00
Linus
a545c1cbd7 Fix a bug where simple loops did not bind let bindings correctly
add check whether a loop clause exists to avoid the ultra-shit errors that happen if you
accidentally write (up-form ...)
2021-02-09 22:02:40 +01:00
Linus
06a11fc892 Modularized the code
Everything in goof-impl.scm is portable (r7rs) syntax-rules. The non-portable parts
, most notably the let-kw-form macro is in the module definition goof.scm.
2021-01-28 20:01:24 +01:00
Linus
93aa5aa439 Simplified the iterator protocol.
There is no need for :acc clauses to intoduce loop variables, or for :for clauses to introduce acc clauses.
They are now changed.

 * goof.scm (cl-next/acc cl-next/for): removed the unused matchings for loop-vars and acc-vars respectively.
 * goof/iterators.scm (all iterators): simplified it.
2021-01-06 21:24:15 +01:00
Linus
7311da2ec2 Add the vectoring accumulator.
Currently undocumented and untested.
2021-01-02 21:43:10 +01:00
Linus
f492a5278b Added hashing, hashqing hashving och in-hash. 2021-01-02 12:03:03 +01:00
Linus
5f96ef4fb0 Promote accumulator lets to the outermost let
This is a bug I never hit, due to me only having accumulators that gets passed along. However,
something like vectoring or hashing should behave like (in-vector ...), which means the let binding
needs to be propagated upwards.
* goof.scm change cl-next/acc to promote let bindings for accumulators to the outermost let.
2021-01-01 22:00:39 +01:00
Linus
7ddb707bb7 Made it a module.
Put it in any directory, run guile -L . and then import (goof) in that directory.
2020-12-16 20:17:13 +01:00
Linus
2d35c9d6cf Polishing the README and iterator protocol.
* README.md: added some small documentation and loop expansion.
 * goof.scm: Changed the iterator protocol to not use unnecessary :acc and :fors.
 * iterators.scm: see above.
 * ref-let.scm: a new macro to allow multiple values and pattern matching to co-exist for body-bindings.
2020-12-16 19:54:55 +01:00
Linus
aab9fcabb0 Extracted the innermost recuring form into a separate form to facilitate inlining
Guile wasn't properly doing DCE when there are no :final guards, so I did it as a macro.
2020-12-02 21:39:47 +01:00
Linus
2dc4a72790 Added pattern matching
ref variables now do pattern matching. This means that, say, the
variable binding the (car cursor) in (in-list ...) can be a (ice-9 match) pattern:

(loop/list (((a . b) (in-list '((1 ignore) (2 ignore) (3 ignore))))
  a)
;; => (1 2 3)
2020-12-02 21:17:42 +01:00
Linus
c53a08c769 Made simple loops better. Now with correct syntax proliferation.w 2020-12-01 20:53:25 +01:00
Linus
0c110dd080 Big, buggy commit
:for clauses now have finalizers! This means (in-file "path") now works. This meant I had to do some restructuring of many nasty pieces of code, but I believe it works. cl-next was broken up into cl-next/acc and cl-next/for. Accumulators have to pass :acc to (cl-next/acc ...). I plan for :for clauses to do the same.

I fixed tests.scm and README.md to reflect the de-racketification of the for loops.
2020-11-25 20:40:48 +01:00
Linus
1a826f86e2 Undid racketification, because not diffrentiating between :for and :acc means that errors become very strange and unhelpful.
Added simple forms, like loop/list that accumulates bodies into a list.

Add :final that works like in racket:
(loop/list ((:for a (in-list '(1 2 3))) :final (= a 2)) (display a))
=> (1 2)
2020-11-22 21:47:48 +01:00
Linus
80464ebe48 Added some simple versions of loop
loop/first loop/last loop/sum loop/product now added.
2020-11-09 23:18:58 +01:00
Linus
17d72f2cea Added generator sequences
Basic hack of in-cycle and in-indexed
2020-11-09 22:57:18 +01:00
Linus
2c182da570 Racketifying goof-loop
I have racketified goof loops. No :for or :acc needed, and :when, :unless, and :break are no longer parethesised.
:acc blah (in ...) and :for blah (in ...) has been changed to
(blah (folding ...)) and (blah (in ...))
2020-11-09 13:30:02 +01:00
Linus
be9ac1a55d Intermediate loops
goof.scm
  * Changed cl-next to properly push all intermediate loops
  * Changed emit-many/rest to emit intermediate loops
  * Added loop/list as a shorthand for just accumulating lists.

tests.scm
  * Collected some things I wanted ta have to track regressions.

README.md
  * Reflect above changes
2020-11-04 23:15:32 +01:00
Linus
f2496604d5 Fixed named update and a bug in accumulating
* goof.scm: Removed positional updates and fixed named updates
 * iterators.scm: Fixed bug in accumulating where only lists were supported.
2020-11-04 11:58:58 +01:00
Linus
ef96da9658 First commit 2020-11-02 22:11:45 +01:00