Skip to content

Instantly share code, notes, and snippets.

View maticzav's full-sized avatar
🎉
Keep moving forward!

Matic Zavadlal maticzav

🎉
Keep moving forward!
View GitHub Profile
@maticzav
maticzav / State.elm
Created November 29, 2016 15:33
Allows you to send new state to JS every time state is changed in Elm program.
withOnStateChangeSub : (model -> Cmd msg) -> (msg -> model -> ( model, Cmd msg )) -> msg -> model -> ( model, Cmd msg )
withOnStateChangeSub statePort update msg model =
let
( updatedModel, cmd ) =
update msg model
updatedCmd : Cmd msg
updatedCmd =
if updatedModel == model then
@maticzav
maticzav / api
Created September 8, 2016 18:44
####<title>
----
**URL**
<url>
**Methods**
`<method>`|`<method>`
**Data Params**
<body>
**Success Response**
<json_resp>
@maticzav
maticzav / main.elm
Last active January 23, 2017 10:55
Elm - get only one element of value from list
unique : List a -> List a
unique list =
case list of
[] ->
[]
x :: [] ->
x :: []
x :: xs ->
@maticzav
maticzav / main.elm
Created July 10, 2016 09:30
Flatten 2D list in Elm
import List exposing (..)
flatten2D : List (List a) -> List a
flatten2D list =
foldr (++) [] list
-- SAMPLE
flatten2D [[1,2],[3,4],[1,1]] == [1,2,3,4,1,1]