[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [4863] add a polymorphic shifter
From: |
Pascal Brisset |
Subject: |
[paparazzi-commits] [4863] add a polymorphic shifter |
Date: |
Thu, 22 Apr 2010 15:38:02 +0000 |
Revision: 4863
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4863
Author: hecto
Date: 2010-04-22 15:38:02 +0000 (Thu, 22 Apr 2010)
Log Message:
-----------
add a polymorphic shifter
Modified Paths:
--------------
paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.ml
paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.mli
Modified: paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.ml
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.ml 2010-04-22 14:40:37 UTC
(rev 4862)
+++ paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.ml 2010-04-22 15:38:02 UTC
(rev 4863)
@@ -67,3 +67,12 @@
fun () ->
x := k *. !x +. normal 0. sigma;
!x
+
+let shifter = fun n default ->
+ let a = Array.create n default
+ and i = ref 0 in
+ fun new_value ->
+ let old_value = a.(!i) in
+ a.(!i) <- new_value;
+ i := (!i + 1) mod n;
+ old_value
Modified: paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.mli
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.mli 2010-04-22 14:40:37 UTC
(rev 4862)
+++ paparazzi3/trunk/sw/lib/ocaml/ocaml_tools.mli 2010-04-22 15:38:02 UTC
(rev 4863)
@@ -46,3 +46,7 @@
(* [make_1st_order_noise_generator ?init k sigma] Returns a generator
initialized to [init], damped by [k] with a variation of stdev [sigma].
0 < [k] < 1 . x_n+1 <- k x_n + normal 0 sigma . *)
+
+val shifter : int -> 'a -> ('a -> 'a)
+(* [shifter size init] Returns a shift register containing [size] values
+ initialized to [init] *)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [4863] add a polymorphic shifter,
Pascal Brisset <=