aivika-gpss-0.6: GPSS-like DSL for Aivika

CopyrightCopyright (c) 2017 David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Simulation.Aivika.GPSS.Block.Split

Description

Tested with: GHC 8.0.2

This module defines an analog of the GPSS block SPLIT.

Synopsis

Documentation

splitBlock Source #

Arguments

:: [Block (Transact a) ()]

split and transfer new transacts to the specified blocks

-> Block (Transact a) (Transact a) 

This is an analog of the GPSS construct

SPLIT A,B,C

Parameter A is a length of the list parameter passed in to the function. Parameter B is the list itself. If you need to define parameter C then you can create the blocks dynamically that could depend on the index and where we could assign a new value for each new transcact after splitting.

An example is

let blocks :: [Block (Transact (a, Int)) ()]
    blocks = ...
    f :: (Int, Block (Transact (a, Int)) ()) -> Block (Transact a) ()
    f (n, block) = assignBlock (a -> (a, n)) >>> block
    blocks' :: [Block (Transact a) ()]
    blocks' = map f $ zip [0..] blocks
in splitBlock blocks'