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

Feature/init array default values #296

Merged
merged 8 commits into from
Nov 10, 2023
Merged

Conversation

IR0NSIGHT
Copy link
Collaborator

@IR0NSIGHT IR0NSIGHT commented Oct 20, 2023

allows initializing a mutable array of size n with default values
skips having to init an array of size n with unknown type values and then having to fill the array with values.

added some QOL features such as init array from a function by index and init array from hardcoded list

fixes #291

@IR0NSIGHT IR0NSIGHT force-pushed the feature/init-array-default-values branch 2 times, most recently from e2821cb to f1496e0 Compare October 25, 2023 10:08
@IR0NSIGHT IR0NSIGHT marked this pull request as ready for review October 25, 2023 10:24
@IR0NSIGHT
Copy link
Collaborator Author

@phischu

Copy link
Collaborator

@phischu phischu left a comment

Choose a reason for hiding this comment

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

Very good job

examples/pos/arrays.effekt Outdated Show resolved Hide resolved
libraries/js/immutable/list.effekt Outdated Show resolved Hide resolved
libraries/js/mutable/array.effekt Outdated Show resolved Hide resolved
@IR0NSIGHT IR0NSIGHT force-pushed the feature/init-array-default-values branch from f1496e0 to 004fb02 Compare November 8, 2023 10:40
@IR0NSIGHT IR0NSIGHT force-pushed the feature/init-array-default-values branch from adab236 to 8663d57 Compare November 8, 2023 11:04
@IR0NSIGHT
Copy link
Collaborator Author

@phischu done

@IR0NSIGHT IR0NSIGHT added the feature New feature or request label Nov 8, 2023
@phischu phischu merged commit 03d9349 into master Nov 10, 2023
2 checks passed
@phischu phischu deleted the feature/init-array-default-values branch November 10, 2023 12:57
def worker[T](list: List[T], i: Int){ f: (Int, T) => Unit}: Unit = {
list match {
case Nil() => ();
case Cons(head, tail) => f(i, head); worker(tail, i+1){f}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@IR0NSIGHT @phischu f is stable throughout the recursion, please consider dropping it from worker.

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

Successfully merging this pull request may close these issues.

initialize array with default values
3 participants