[elm-discuss] Re: Array map with start and end

2017-11-27 Thread Matthieu Pizenberg
Following your advice, I came back to elm 0.18 and just started a repository to try to wrap JS typed arrays in elm. I've moved the discussion to a new post [1] since we were drifting from the original post here. Cheers [1] JS typed array implementation for elm:

Re: [elm-discuss] Re: Array map with start and end

2017-11-23 Thread Robin Heggelund Hansen
Using native code in Elm isn't particularly hard (though, you cannot publish such code as an elm package). My original, and still working, array implementation uses native code (it's a "blessed" library). It's better to use that as a template for any experimentation you might want to do:

Re: [elm-discuss] Re: Array map with start and end

2017-11-23 Thread Matthieu Pizenberg
> > Do you need to rebuild the compiler for this? > I'm not familiar with so called "native" elm 0.18 code. So I wanted to use the example given by Robin with `Elm/JsArray.elm` and `Elm/Kernel/JsArray.js` from elm master branch to try the same thing with `JsArrayBuffer.[elm/js]`. Since this

Re: [elm-discuss] Re: Array map with start and end

2017-11-23 Thread 'Rupert Smith' via Elm Discuss
On Thursday, November 23, 2017 at 2:28:50 AM UTC, Matthieu Pizenberg wrote: > > > Could JsArray.elm by made to work with JavaScript typed arrays? >> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays >> > > That was exactly what I was wondering. I peaked at the elm and kernel

Re: [elm-discuss] Re: Array map with start and end

2017-11-22 Thread 'Rupert Smith' via Elm Discuss
On Tuesday, November 21, 2017 at 10:47:02 AM UTC, Robin Heggelund Hansen wrote: > > Something like > https://github.com/Skinney/core/blob/master/src/Elm/JsArray.elm ? It's > what is used as the basis for Arrays in 0.19. It is not planned to be > opened for use outside of elm-lang/core, but if

Re: [elm-discuss] Re: Array map with start and end

2017-11-21 Thread Robin Heggelund Hansen
Something like https://github.com/Skinney/core/blob/master/src/Elm/JsArray.elm ? It's what is used as the basis for Arrays in 0.19. It is not planned to be opened for use outside of elm-lang/core, but if it fits your usecase better, I'm sure Evan would be interested in hearing about it.

Re: [elm-discuss] Re: Array map with start and end

2017-11-21 Thread 'Rupert Smith' via Elm Discuss
On Monday, November 20, 2017 at 5:29:25 PM UTC, Francisco Ramos wrote: > > Ultimately, I'd like to rewrite NumElm using the elm-ndarray. Not sure how > I'm gonna do this without writing kernel code. Linear algebra operations > such as Inverse, Pseudo-inverse, Singular value decomposition,

Re: [elm-discuss] Re: Array map with start and end

2017-11-20 Thread Francisco Ramos
Hi guys, Thanks for your answers. Robin, that was a great talk. I actually was in that very same room when you gave the presentation :-). Very interesting and educative. Hope to see you again in the next Elm Europe. Matthieu, thanks for the info. I didn't know about Okasaki's work on immutable

Re: [elm-discuss] Re: Array map with start and end

2017-11-20 Thread Matthieu Pizenberg
Hi again, So out of curiosity, I just spend a couple hours looking for variations of: "(immutable/persistent) (tensor/multidimentional array/multidimentional data structure) implementation" and my conclusion is that I did not easily find examples of implementations of data structures tailored

Re: [elm-discuss] Re: Array map with start and end

2017-11-20 Thread Robin Heggelund Hansen
It using Array.prototype.slice under the hood, but the way Arrays in Elm is implemented is by using trees. I suggest you watch my talk from Elm Europe, where I explain how the different data structures work in detail =) https://www.youtube.com/watch?v=mmiNobpx7eI fredag 17. november 2017

Re: [elm-discuss] Re: Array map with start and end

2017-11-20 Thread Francisco Ramos
Hi Matthieu, Thanks for those links!!. Those lazy views look like what I'm trying to achieve. I'm actually working on a multidimensional container of items, elm-ndarray, https://github.com/jscriptcoder/elm-ndarray/blob/master/src/NdArray.elm. Still some work to do. I need to re-write *map* and

[elm-discuss] Re: Array map with start and end

2017-11-19 Thread Matthieu Pizenberg
Hi Francisco, just a few words about arrays and image manipulation. I've been doing some work along this way and encountered multiple issues. One of them was with slicing. If I'm not wrong Robin's work will be merged in 0.19 but meanwhile, you should be aware that there are few issues with the

[elm-discuss] Re: Array map with start and end

2017-11-17 Thread Rémi Lefèvre
Hi, Does using Array.indexedMap suit you? import Array exposing (Array) submap : Int -> Int -> (a -> a) -> Array a -> Array a submap start end func = Array.indexedMap (\i -> if i >= start && i < end then func else identity) Of course the result must be of the same type in this case. On

Re: [elm-discuss] Re: Array map with start and end

2017-11-17 Thread Francisco Ramos
That was a good observation, Rupert. Well, it doesn't return Nothing if the indexes are out of the bounds, but if start < 0 then start = 0, and end >= length then end = length -1... I could actually use Array.get and implement my own map like you mention. Thanks Robin for that correction. I

[elm-discuss] Re: Array map with start and end

2017-11-17 Thread Robin Heggelund Hansen
Slicing isn't O(N). In the current implementation in core, slicing is O(log32n) i believe. In the next version of Elm, slicing is O(log32n) when start = 0; I'm uncertain what the big-o notation is once start > 0 though. fredag 17. november 2017 09.25.22 UTC+1 skrev Francisco Ramos følgende: >

[elm-discuss] Re: Array map with start and end

2017-11-17 Thread 'Rupert Smith' via Elm Discuss
On Friday, November 17, 2017 at 8:25:22 AM UTC, Francisco Ramos wrote: > > Hi there, > > Was wondering how I can map over an array with a start and end indexes. I > know I could slice the array and then map, but performance is a concern and > slicing is O(N) where N = end - start, plus the