Skip to content

Commit

Permalink
[#328] [stbx-core] Reduce intermediate data structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
epost authored and marcosh committed Feb 20, 2020
1 parent 1220cef commit d42c87c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions stbx-core/src/Statebox/Core/WiringTree.purs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ linearizeTransitionsAndNames transitions names =
sortInitialFinal $ lift3 buildGluedTransition (range 0 (length transitions - 1)) transitions names

buildGluedTransition :: TID -> TransitionF' PID -> String -> Glued Transition
buildGluedTransition tId (pre /\ post) name =
case (pre /\ post) of
([] /\ _ ) -> Initial { name: name, path: [0, 0, 0], transition: tId, tokens: buildTokens pre post } -- the path is [0, 0, 0] because we consider a trivial diagram to be there
(_ /\ [] ) -> Final { name: name, path: [0, 0, 0], transition: tId, tokens: buildTokens pre post }
(inp /\ out) -> Untouched { name: name, path: [0, 0, 0], transition: tId, tokens: buildTokens pre post }
buildGluedTransition tid (pre /\ post) name =
case pre, post of
[], _ -> Initial { name: name, path: [0, 0, 0], transition: tid, tokens: buildTokens pre post } -- the path is [0, 0, 0] because we consider a trivial diagram to be there
_ , [] -> Final { name: name, path: [0, 0, 0], transition: tid, tokens: buildTokens pre post }
_ , _ -> Untouched { name: name, path: [0, 0, 0], transition: tid, tokens: buildTokens pre post }

-- | We use this custom function instead of `sortBy` because that does not guarantee
-- | the order of equal elements to be preserved.
Expand Down

0 comments on commit d42c87c

Please sign in to comment.