OOP initial commit with new tracked files.
[Faustine.git] / interpretor / beam.ml
diff --git a/interpretor/beam.ml b/interpretor/beam.ml
new file mode 100644 (file)
index 0000000..33fb08e
--- /dev/null
@@ -0,0 +1,41 @@
+(**
+       Module: Beam    
+       Description: beam definition and operations
+       @author WANG Haisheng   
+       Created: 21/07/2013     Modified: 21/07/2013
+*)
+
+exception Beam_matching of string;;
+
+open Signal;;
+
+class beam : signal_type array -> beam_type = 
+  fun (sa_init : signal_type array) ->
+    object (self)
+      val sa = sa_init
+      val l = Array.length sa
+
+      method get = sa
+
+      method length = l
+
+      method sub : int -> int -> beam_type = 
+       fun start ->
+         fun len ->
+           new beam (Array.sub self#get start len)
+
+      method append : beam_type -> beam_type =
+       fun b -> 
+         new beam (Array.append self#get b)
+         
+      method matching : int -> beam_type
+         fun size ->
+           if size = self#length then self
+           else if size > self#length && size mod self#length = 0 then
+             
+           else if size < self#length && self#length mod size = 0 then
+             
+           else raise (Beam_matching "matching size error")
+
+
+    end