Part of TeSSLa Petri net monitoring implementation. Meant for internal use only.
liftable addTimes[A](l: List[A], times: Int, el: A): List[A]
liftable appendList[A](l: List[A], l2: List[A]): List[A]
liftable def appendList[A](l: List[A], l2: List[A]) : List[A] = {
List.fold(l2, l, (lst: List[A], el: A) => List.append(lst, el))
}
asyncAdd(a: Events[Int], b: Events[Int]): Events[Int]
def asyncAdd(a: Events[Int], b: Events[Int]): Events[Int] = {
lift(a, b, (ae,be) => {
if isSome(ae) && isSome(be) then
Some(getSome(ae) + getSome(be))
else if isSome(ae) then
ae
else
be
})
}
liftable listAvg(l: List[Int]): Float
liftable def listAvg(l: List[Int]): Float = {
def sum = List.fold(l, 0, (c: Int, e: Int) => c + e)
intToFloat(sum) /. intToFloat(List.size(l))
}
liftable listMin(l: List[Int]): Int
liftable def listMin(l: List[Int]): Int = {
def min = List.fold(l, None, (c: Option[Int], e : Int) => if isNone(c) || getSome(c) >= e then Some(e) else c)
getSome(min)
}
liftable prependList[A](l: List[A], l2: List[A]): List[A]
liftable def prependList[A](l: List[A], l2: List[A]) : List[A] = {
List.fold(l2, l, (lst: List[A], el: A) => List.prepend(el, lst))
}
liftable removeNFront[A](l: List[A], n: Int): List[A]
liftable def removeNFront[A](l: List[A], n: Int) : List[A] = {
if n <= 0 then l else List.tail(removeNFront(l,n-1))
}
liftable removeNFrontColl[A](l: List[A], n: Int): (List[A], List[A])
liftable def removeNFrontColl[A](l: List[A], n: Int) : (List[A], List[A]) = {
if n <= 0 then (l, List.empty[A]) else {
def nlsts = removeNFrontColl(l,n-1)
(List.tail(nlsts._1), List.append(nlsts._2, List.head(nlsts._1)))
}
}