Cellular automata in Elm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

56 lines
1002 B

import Zipper exposing (..)
import Color exposing (Color)
import Dict exposing (Dict)
import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Random
import Time
main =
App.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
size = 1000
-- MODEL
type alias Model = Zipper Int
init : (Model, Cmd Msg)
init = (fromList 0 [1..size], Cmd.none)
-- UPDATE
type Msg = Update (Zipper Int)
succ n = n + 1
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Update grid -> (edit succ grid, Cmd.none)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model = Sub.none
-- VIEW
buttonView : Zipper Int -> Html Msg
buttonView zppr = button [onClick (Update zppr)] [text <| toString <| extract zppr]
view model = let
butts = model =>> buttonView
listm = List.intersperse (br [] []) (toList butts)
in div [] listm