Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module type PETRI_TYPES = sig
- type node
- type place
- type token
- val node_id : node -> int
- end
- module Petri_net =
- functor (PTypes : PETRI_TYPES) ->
- struct
- type node = PTypes.node
- type place = PTypes.place
- type token = PTypes.token
- type transition = ( node list * place * node list)
- class petri_net (places_i ) (nodes_i ) (transitions_i ) =
- object
- val places = places_i
- val nodes = nodes_i
- val transitions = transitions_i
- val places_number = Array.length places_i
- method check_init =
- let rec check_transition t =
- (* si on faisait du coq, ce serait encore plus beau *)
- match t with
- | h :: t, l2 ->
- PTypes.node_id h >= 0 && PTypes.node_id h < places_number && check_transition (t,l2)
- | [], h :: t ->
- PTypes.node_id h >= 0 && PTypes.node_id h < places_number && check_transition ([],t)
- | _ -> true
- and check_transitions t_list =
- match t_list with
- | [] -> true
- | t :: t_list' ->
- check_transition t && check_transitions t_list'
- in
- check_transitions transitions
- end
- end;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement