Skip to content

DList (Difference List) #214

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

Merged
merged 2 commits into from
Feb 5, 2016
Merged

DList (Difference List) #214

merged 2 commits into from
Feb 5, 2016

Conversation

clinuxrulz
Copy link
Contributor

Difference List is designed for efficient appending to the end of lists.

Edit:
Benchmark: http://pastebin.com/k2n8m9UN

Average over 10 runs...
List: 1422.8ms
Seq: 187.6ms
DList: 3.9ms

The benchmark is the average of 10 runs of appending 2000 lists each containing 100 elements.

return new DList<>(kleisliTrampCompose(this.appendFn, other.appendFn));
}

private static <A,B,C> F<A,Trampoline<C>> kleisliTrampCompose(F<B,Trampoline<C>> bc, F<A,Trampoline<B>> ab) {
Copy link
Member

Choose a reason for hiding this comment

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

Could this be useful as a public method of Trampoline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its not really a true Kleisli composition, because of the use of Trampoline.suspend(...). But a bit of careful rearrangement compose could be added and used from Trampoline.

@jbgi
Copy link
Member

jbgi commented Feb 3, 2016

👍 probably need some javadoc though...

@mperry
Copy link
Contributor

mperry commented Feb 4, 2016

Looks good. We should add the benchmarks to the code somewhere. Perhaps we need a new module for this (e.g. benchmarks). There have been various PRs related to performance that we should keep the evidence for.

@clinuxrulz
Copy link
Contributor Author

I agree with keeping the benchmarks somewhere. The first time I've seen DList on Hackage, I could not make sense of how it helped the performance.

A separate module called benchmarks would be fine. I'm not experienced enough with Gradle to do it myself.

@mperry
Copy link
Contributor

mperry commented Feb 5, 2016

I created #224 for the evidence of the DList. I will merge this PR now.

mperry added a commit that referenced this pull request Feb 5, 2016
@mperry mperry merged commit cf10026 into functionaljava:master Feb 5, 2016
@clinuxrulz clinuxrulz deleted the DList branch February 6, 2016 04:48
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