MOve it forwards a bit

This commit is contained in:
Nathan Braswell
2017-06-13 01:29:56 -04:00
3 changed files with 9 additions and 4 deletions

View File

@@ -96,4 +96,10 @@ obj stack<T> (Object, Serializable) {
fun item_from_top_satisfying(func: fun(T):bool): T {
return from_top(index_from_top_satisfying(func))
}
fun item_from_top_satisfying_or(func: fun(T):bool, other: T): T {
var idx = index_from_top_satisfying(func)
if (idx != -1)
return from_top(idx)
return other
}
}