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

Chapter: Lists #13

Open
rauschma opened this Issue Feb 7, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@rauschma
Owner

rauschma commented Feb 7, 2018

No description provided.

@geraldodev

This comment has been minimized.

geraldodev commented Feb 21, 2018

No need rec on summarize that uses fold_left

 let rec summarize = (l: list(int)) =>
   ListLabels.fold_left(~f=(r, elem) => r + elem, ~init=0, l);
@geraldodev

This comment has been minimized.

geraldodev commented Feb 21, 2018

/**

  • Inside the list l, remove all occurrences of the value ~value
  • with the value ~with_.
    */
    The replace comment retained the remove from the previous example. I think it is : replace all occurrences...
@eugrdn

This comment has been minimized.

eugrdn commented Apr 1, 2018

Guys, could you help to understand the phrase: "Note that concatenating lists is comparatively slow, because you must prepend each element of the first operand to the second operand..".
Is that makes sense how it slow or quick the operation, if it will become the common js operation after the OCaml to JS compilation? I mean that we do concatenation in js by the Array.concat, and is that exactly this method we will use in compiled to js code?

@rauschma

This comment has been minimized.

Owner

rauschma commented Apr 1, 2018

@geraldodev Could you put lines with three backticks before and after your code, like this:

```
this is the code
```

Currently your comments are hard to read and understand (GitHub lets you edit existing comments).

@rauschma

This comment has been minimized.

Owner

rauschma commented Apr 1, 2018

@eugrdn I take it you understand why the operation is slow?

If you concatenate often, it’s better to switch to arrays. ReasonML also lets you convert between lists and arrays, so you can use each of them for what they do well, as described in the following table: http://reasonmlhub.com/exploring-reasonml/ch_arrays.html#lists-vs.arrays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment