From 397f768ca30a4615c753ec544dedc5c39be7743b Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Sat, 5 Aug 2006 19:24:17 +0000 Subject: added PersistentList, changed RT.cons to work with all collections --- src/cli/runtime/PersistentListMap.cs | 47 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'src/cli/runtime/PersistentListMap.cs') diff --git a/src/cli/runtime/PersistentListMap.cs b/src/cli/runtime/PersistentListMap.cs index 272ca299..e632a67a 100644 --- a/src/cli/runtime/PersistentListMap.cs +++ b/src/cli/runtime/PersistentListMap.cs @@ -27,7 +27,7 @@ namespace clojure.lang * * null keys and values are ok, but you won't be able to distinguish a null value via get - use contains/find */ -public class PersistentListMap : APersistentMap, IMapEntry, ISeq +public class PersistentListMap : APersistentMap, IMapEntry { static public PersistentListMap EMPTY = new PersistentListMap(); @@ -218,19 +218,25 @@ internal class Tail : PersistentListMap { return this; } - override public Object first() - { - return this; - } + class Seq : ASeq{ + Tail t; - override public ISeq rest() - { - return null; - } + public Seq(Tail t) { + this.t = t; + } + override public Object first() + { + return t; + } + override public ISeq rest() + { + return null; + } + } override public ISeq seq() { - return this; + return new Seq(this); } } @@ -317,20 +323,25 @@ internal class Link : PersistentListMap { return null; } + class Seq : ASeq{ + Link lnk; - override public Object first() - { - return this; - } + public Seq(Link lnk) { + this.lnk = lnk; + } - override public ISeq rest() - { - return _rest; + override public Object first() { + return lnk; + } + + override public ISeq rest() { + return lnk._rest.seq(); + } } override public ISeq seq() { - return this; + return new Seq(this); } PersistentListMap create(Object k, Object v, IPersistentMap r) -- cgit v1.2.3-70-g09d2