-
Notifications
You must be signed in to change notification settings - Fork 14
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
Added x and xx example, fixes #278. Also fixes tutorial. #286
Conversation
I just discovered this PR. Good work! I will comment on lines of code individually, but what I see already looks good enough that I'd like to merge ASAP. Re your two questions:
|
sub flatten (inputList) { | ||
my result = []; | ||
for inputList -> i { | ||
if (type(i) == type([])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but more idiomatic to use type matching: if i ~~ Array
.
if (type(i) == type([])) { | ||
for i -> j { | ||
result.push(j); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shorter and no less clear than the for
loop might be to do result = result.concat(i);
— this appends all the elements "at once" at the expense of creating a brand new array and letting the old one be collected.
return quasi { | ||
flatten((^{{{right}}}).map(sub getValue(ignore) { | ||
return {{{left}}}; | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is beautiful. ❤️
|
||
# Test (list or number) xx number. | ||
my j = 0; | ||
say((j = [1, [1, 2, 3]][j && 1]) xx 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries for now, but given the way #279 is heading, this expression might become illegal soon. Just a heads-up. 😄 It's an interesting way to check for something — if we outlaw assignment expressions, we'll have to make sure to have an alternative in place for this one.
All I made was minor, non-merge-blocking comments, so I'm going to go ahead and merge this now. Again, great work, especially for a first contribution! |
This PR adds an x and xx example (removing the hello world example). It also updates the tutorial's lists of builtin functions and methods (though it does not include regex or type methods). (The reason I updated the tutorial was that I didn't know about the concat or push list methods and so initially wrote a big mess. I don't want anyone else making the same mistake.)
Potential issues: