summaryrefslogtreecommitdiff
path: root/Chalice/src/Chalice.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Chalice/src/Chalice.cs')
-rw-r--r--Chalice/src/Chalice.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Chalice/src/Chalice.cs b/Chalice/src/Chalice.cs
new file mode 100644
index 00000000..f4a804e7
--- /dev/null
+++ b/Chalice/src/Chalice.cs
@@ -0,0 +1,76 @@
+//-----------------------------------------------------------------------------
+//
+// Copyright (C) Microsoft Corporation. All Rights Reserved.
+//
+//-----------------------------------------------------------------------------
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Chalice
+{
+ public class ImmutableList<E>
+ {
+ private List<E> list;
+
+ public ImmutableList() {
+ list = new List<E>();
+ }
+
+ public ImmutableList(IEnumerable<E> elems)
+ {
+ list = new List<E>(elems);
+ }
+
+ public ImmutableList<E> Append(ImmutableList<E> other)
+ {
+ var res = new ImmutableList<E>();
+ res.list.AddRange(list);
+ res.list.AddRange(other.list);
+ return res;
+ }
+
+ public E At(int index)
+ {
+ return list[index];
+ }
+
+ public ImmutableList<E> Take(int howMany)
+ {
+ var res = new ImmutableList<E>(this.list.Take(howMany));
+ return res;
+ }
+
+ public ImmutableList<E> Drop(int howMany)
+ {
+ var res = new ImmutableList<E>(this.list.Skip(howMany));
+ return res;
+ }
+
+ public int Length
+ {
+ get
+ {
+ return list.Count;
+ }
+ }
+
+ public static ImmutableList<int> Range(int min, int max)
+ {
+ ImmutableList<int> l = new ImmutableList<int>();
+ for (int i = min; i < max; i++)
+ {
+ l.list.Add(i);
+ }
+ return l;
+ }
+ }
+
+ public class ChalicePrint {
+ public void Int(int x) {
+ System.Console.WriteLine(x);
+ }
+ public void Bool(bool x) {
+ System.Console.WriteLine(x);
+ }
+ }
+}