Recency.pudu
1/** @Log.Domain.Recency.Module — keys ordered from least to most recently used */2module PuduLangLog.Domain.Recency34import Std.List as List5import Std.Math as Math67/// The keys with `key` moved to, or added at, the most recent end.8export fn touch(keys: &Array[Str], key: Str) -> Array[Str] { keys.filter(|kept: Str| kept != key).push(key) }910/// The least recent keys to retire so that at most `limit` remain; a negative limit counts as zero.11export fn overflow(keys: &Array[Str], limit: Int) -> Array[Str] { List.take(keys, keys.length() - Math.max(0, limit)) }12