On Tue, Oct 25, 2016 at 11:12 PM, Did <[email protected]> wrote:
> Now is the hardest part for me : the update function. Since elm is a
> functional language, I suppose I have to recreate a new cells list with the
> value of the box concerned by the click. In OOP languages, I'd just take
> the reference of the box from the list, change the player and that's it...
> Here is the update function with some not working changes...
>
> CELLS_WITH_BOX_UPDATED would be the new cells list updated but I don't
> understand how to do this...
>
`cells` is a list of lists.
updated cells would mean that you would have to update all the list in the
main list, in other words, update every row
let
currentBox = List.map (filterRow boxId) model.cells
updateRow row = List.map (\box -> if boxId == box.id then {box | shape
= Just model.current } else box) row
in
case currentBox of
Nothing ->
{ model | cells = List.map updateRow model.cells, current
= changePlayer
model.current }
Just _ ->
model -- nothing changes (cannot click over a previous ticked
cell)
--
There is NO FATE, we are the creators.
blog: http://damoc.ro/
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.