Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Bug: SRFI 1 fold and fold-right #190 #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Duolei-Wang
Copy link
Collaborator

I implement the fold, fold-right for variant parameters. I added two simple cases provided by the srfi-1 about the cons. As I didn't find an "unpack", I use "apply" to represent. As I'm not very familiar with variant parameters, please check them.
@Ancker-0 @da-liii

As I'm not very familiar with variant parameters; please check them.

I added two simple cases provided by the srfi-1 about the cons. As I didn't find an "unpack", I use "apply" to represent.
initial
(cdr l)))))
(define (fold f accum . lsts)
(if (eq? 1 (length lsts))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保留一下type-error,现在的syntax-error报错在内部,无法有效判断具体的错误原因

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length的时间复杂度为O(n),通过length判断判断列表长度是否为1,时间复杂度过高

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前这个实现有很大的问题,建议看一下官方的实现:https://github.com/scheme-requests-for-implementation/srfi-1/blob/master/srfi-1-reference.scm#L832-L842

@Ancker-0
Copy link
Contributor

I suggest add (fold + 0) to the test. The srfi requires at least one list, so it should raise an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants