Advertisement
Guest User

Untitled

a guest
Sep 28th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 1.16 KB | None | 0 0
  1.  
  2. module type PETRI_TYPES = sig
  3.  
  4.   type node
  5.   type place
  6.   type token
  7.   val node_id : node -> int
  8. end
  9.  
  10. module Petri_net =
  11.   functor (PTypes  : PETRI_TYPES) ->
  12. struct
  13.   type node = PTypes.node
  14.   type place = PTypes.place
  15.   type token = PTypes.token
  16.  
  17.   type transition = ( node list * place * node list)
  18.  
  19.  
  20.   class petri_net (places_i ) (nodes_i ) (transitions_i ) =
  21.   object
  22.  
  23.     val places = places_i
  24.     val nodes = nodes_i
  25.     val transitions = transitions_i
  26.  
  27.     val places_number = Array.length places_i
  28.  
  29.     method check_init =
  30.       let rec check_transition t =
  31.       (* si on faisait du coq, ce serait encore plus beau *)
  32.         match t with
  33.         | h :: t, l2 ->
  34.            PTypes.node_id h >= 0 && PTypes.node_id h < places_number && check_transition (t,l2)
  35.         | [], h :: t ->
  36.            PTypes.node_id h >= 0 && PTypes.node_id h < places_number && check_transition ([],t)
  37.         | _ -> true
  38.  
  39.       and check_transitions t_list =
  40.         match t_list with
  41.         | [] -> true
  42.         | t :: t_list' ->
  43.            check_transition t && check_transitions t_list'
  44.       in
  45.       check_transitions transitions
  46.  
  47.  
  48.   end
  49. end;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement