Beispiel #1
0
 public static void DumpDictionary(object stream, PrototypeDictionary dict)
 {
     if (dict != null)
     {
         foreach (var key in ToIter(SeqBase.Sort(dict.Keys, CompareApply, IdentityApply)))
         {
             object val  = dict[key];
             string line = string.Format("{0} => ", key);
             Write(line, Symbols.Escape, false, Symbols.Stream, stream);
             PrettyPrintLine(stream, line.Length, null, val);
         }
     }
 }
Beispiel #2
0
        public static bool EvalFeatureExpr(object expr)
        {
            if (expr == null)
            {
                return(false);
            }
            else if (expr is bool)
            {
                return((bool)expr);
            }
            else if (expr is Symbol)
            {
                return(HasFeature(((Symbol)expr).Name));
            }
            else if (expr is Cons)
            {
                var list = (Cons)expr;
                var oper = First(list) as Symbol;
                if (oper != null)
                {
                    if (oper.Name == "and")
                    {
                        return(SeqBase.Every(EvalFeatureExpr, list.Cdr));
                    }
                    else if (oper.Name == "or")
                    {
                        return(SeqBase.Any(EvalFeatureExpr, list.Cdr));
                    }
                    else if (oper.Name == "not")
                    {
                        return(!EvalFeatureExpr(Second((Cons)expr)));
                    }
                }
            }

            throw new LispException("Invalid feature expression");
        }
Beispiel #3
0
 public static Cons Cycle(IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Cycle(seq)));
 }
Beispiel #4
0
 public static Cons TakeWhile(IApply predicate, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.TakeWhile(predicate, seq)));
 }
Beispiel #5
0
 public static Cons Take(int count, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Take(count, seq)));
 }
Beispiel #6
0
 public static Cons Shuffle(IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Shuffle(seq)));
 }
Beispiel #7
0
 public static Cons Repeatedly(int count, IApply func)
 {
     return(AsLazyList(SeqBase.Repeatedly(count, func)));
 }
Beispiel #8
0
 public static Cons Repeat(object value)
 {
     return(AsLazyList(SeqBase.Repeat(-1, value)));
 }
Beispiel #9
0
 public static Cons Interpose(object separator, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Interpose(separator, seq)));
 }
Beispiel #10
0
 public static Cons Interleave(params IEnumerable[] seqs)
 {
     return(AsLazyList(SeqBase.Interleave(seqs)));
 }
Beispiel #11
0
 public static Cons GroupBy(IApply key, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.GroupBy(key, seq)));
 }
Beispiel #12
0
 public static Cons Flatten(IEnumerable seq, int depth)
 {
     return(AsLazyList(SeqBase.Flatten(seq, depth)));
 }
Beispiel #13
0
 public static Cons Flatten(IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Flatten(seq, int.MaxValue)));
 }
Beispiel #14
0
 public static Cons DropWhile(IApply predicate, IEnumerable seq)
 {
     return(MakeCons(SeqBase.DropWhile(predicate, seq).GetEnumerator()));
 }
Beispiel #15
0
 public static Cons Drop(int count, IEnumerable seq)
 {
     return(MakeCons(SeqBase.Drop(count, seq)));
 }
Beispiel #16
0
 public static Cons Range(int start, int end, int step)
 {
     return(AsLazyList(SeqBase.Range(start, end, step)));
 }
Beispiel #17
0
 public static Cons Repeat(int count, object value)
 {
     return(AsLazyList(SeqBase.Repeat(count, value)));
 }
Beispiel #18
0
 public static Cons Iterate(IApply func, object value)
 {
     return(AsLazyList(SeqBase.Iterate(-1, func, value)));
 }
Beispiel #19
0
 public static Cons Repeatedly(IApply func)
 {
     return(AsLazyList(SeqBase.Repeatedly(-1, func)));
 }
Beispiel #20
0
 public static Cons Map(KeyFunc func, params IEnumerable[] seqs)
 {
     return(AsLazyList(SeqBase.Map(func, seqs)));
 }
Beispiel #21
0
 public static Cons Reverse(IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Reverse(seq)));
 }
Beispiel #22
0
 public static Cons ParallelMap(IApply action, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.ParallelMap(action, seq)));
 }
Beispiel #23
0
 public static Cons Subseq(IEnumerable seq, int start, params object[] args)
 {
     return(AsLazyList(SeqBase.Subseq(seq, start, args)));
 }
Beispiel #24
0
 public static Cons Append(params IEnumerable[] seqs)
 {
     return(AsLazyList(SeqBase.Append(seqs)));
 }
Beispiel #25
0
 public static Cons TakeNth(int step, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.TakeNth(step, seq)));
 }
Beispiel #26
0
 public static Cons Partition(int size, int step, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Partition(false, size, step, null, seq)));
 }
Beispiel #27
0
 public static Cons Zip(params IEnumerable[] seqs)
 {
     return(AsLazyList(SeqBase.Zip(seqs)));
 }
Beispiel #28
0
 public static Cons PartitionAll(int size, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.Partition(true, size, size, null, seq)));
 }
Beispiel #29
0
 public static Cons PartitionBy(IApply func, IEnumerable seq)
 {
     return(AsLazyList(SeqBase.PartitionBy(func, 0, seq)));
 }
Beispiel #30
0
 public static IEnumerable SeriesEnumerator(int start, int end, int step)
 {
     return(SeqBase.Range(start, end + step, step));
 }