Skip to content

Conversation

@kevinsimper
Copy link
Contributor

This is good for a beginner to see how ReasonML is handling looping over an array.

How the array is giving as a argument.

@kevinsimper
Copy link
Contributor Author

Hi @rickyvetter, what do you think of this PR? :)

Copy link
Contributor

@yawaramin yawaramin left a comment

Choose a reason for hiding this comment

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

I recommend moving the examples inside the existing 'Array' table ( https://reasonml.github.io/docs/en/syntax-cheatsheet#array ) instead of creating a new table.


| JavaScript | Reason |
|------------------------------------------|-------------------------------------------|
|`[1,2,3].forEach(i => { console.log(i) })`|`Array.iter(i => { Js.log(i) }, [|1,2,3|])`|
Copy link
Contributor

Choose a reason for hiding this comment

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

Reason version can be Array.iter(Js.log, [|1, 2, 3|])

| JavaScript | Reason |
|------------------------------------------|-------------------------------------------|
|`[1,2,3].forEach(i => { console.log(i) })`|`Array.iter(i => { Js.log(i) }, [|1,2,3|])`|
|`[1,2,3].map(i => { return i + 1 })` |`Array.map(i => i + 1, [|1,2,3|])` |
Copy link
Contributor

Choose a reason for hiding this comment

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

Reason version can be Array.map(succ, [|1, 2, 3|]). Admittedly i => i + 1 is just as valid but if we want to show the idiomatic way of doing things in OCaml/Reason we might as well teach the built-in functions...

@kevinsimper kevinsimper closed this Dec 6, 2019
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.

2 participants