From bc5dc23be88ad294d86d8d2b09583c41eafdd9b9 Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Sat, 30 Sep 2006 00:02:23 +0000 Subject: added findKey --- src/cli/runtime/RT.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/cli/runtime') diff --git a/src/cli/runtime/RT.cs b/src/cli/runtime/RT.cs index 1f97c081..5cf4187f 100644 --- a/src/cli/runtime/RT.cs +++ b/src/cli/runtime/RT.cs @@ -196,6 +196,21 @@ static public Object find(Object key, Object coll) return ((Associative)coll).find(key); } + //takes a seq of key,val,key,val +//returns tail starting at val of matching key if found, else null +static public ISeq findKey(Keyword key,ISeq keyvals) { + while(keyvals != null) + { + ISeq r = keyvals.rest(); + if (r == null) + throw new Exception("Malformed keyword argslist"); + if (keyvals.first() == key) + return r; + keyvals = r.rest(); + } + return null; +} + static public Object without(Object key, Object coll) { if (coll == null) -- cgit v1.2.3-70-g09d2