コード例 #1
0
    public static void SetOutput(IPersistentCollection output)
    {
        ISeq seq = output.seq();
        var  app = NetOffice.ExcelApi.Application.GetActiveInstance();

        NetOffice.ExcelApi.Range sel = (NetOffice.ExcelApi.Range)app.Selection;

        var rawArray = sel.Value as Object[, ];

        if (rawArray != null)
        {
            int a = rawArray.GetLowerBound(0);
            int b = rawArray.GetUpperBound(0);
            int c = rawArray.GetLowerBound(1);
            for (var i = a; i <= b; i++)
            {
                if (rawArray[i, c] != null)
                {
                    rawArray[i, c] = seq.first();
                    seq            = seq.next();
                }
            }
            sel.Value = rawArray;
        }
        else
        {
            sel.Value = seq.first();
        }
    }
コード例 #2
0
ファイル: ConsTests.cs プロジェクト: ryrency/Misc
        public void IPC_Cons_works()
        {
            Cons c1 = new Cons("abc", null);
            IPersistentCollection ipc1 = c1 as IPersistentCollection;

            IPersistentCollection ipc2 = ipc1.cons("def");
            ISeq s = ipc2.seq();

            Expect(s.first(), EqualTo("def"));
            Expect(s.next(), SameAs(c1));
        }
コード例 #3
0
ファイル: ConsTests.cs プロジェクト: redchew-fork/clojure-clr
        public void IPC_Cons_works()
        {
            Cons c1 = new Cons("abc", null);
            IPersistentCollection ipc1 = c1 as IPersistentCollection;

            IPersistentCollection ipc2 = ipc1.cons("def");
            ISeq s = ipc2.seq();

            Expect(s.first()).To.Equal("def");
            Expect(Object.ReferenceEquals(s.next(), c1));
        }
コード例 #4
0
        public void EmptyReturnsEmpty()
        {
            Dictionary <int, string> d = new Dictionary <int, string>();

            d[1] = "a";
            d[2] = "b";
            IPersistentMap        m = PersistentArrayMap.create(d);
            IPersistentCollection c = m.empty();

            Expect(c.count(), EqualTo(0));
            Expect(c.seq(), Null);
        }
コード例 #5
0
        public void Explicit_IPersistentCollection_cons_works()
        {
            CPV v = new CPV(new object[] { 1, 2 });
            IPersistentCollection c = v as IPersistentCollection;

            Expect(c, Not.Null);

            IPersistentCollection c2 = c.cons(3);

            Expect(c2.count(), EqualTo(3));

            ISeq s2 = c2.seq();

            Expect(s2.first(), EqualTo(1));
            Expect(s2.next().first(), EqualTo(2));
            Expect(s2.next().next().first(), EqualTo(3));
            Expect(s2.next().next().next(), Null);
        }
コード例 #6
0
        public void Explicit_IPersistentCollection_cons_works()
        {
            CPV v = new CPV(new object[] { 1, 2 });
            IPersistentCollection c = v as IPersistentCollection;

            Expect(c).Not.To.Be.Null();

            IPersistentCollection c2 = c.cons(3);

            Expect(c2.count()).To.Equal(3);

            ISeq s2 = c2.seq();

            Expect(s2.first()).To.Equal(1);
            Expect(s2.next().first()).To.Equal(2);
            Expect(s2.next().next().first()).To.Equal(3);
            Expect(s2.next().next().next()).To.Be.Null();
        }
コード例 #7
0
ファイル: MyRibbon.cs プロジェクト: telefunkenvf14/Excel-REPL
    public static void SetOutput(IPersistentCollection output)
    {
        ISeq seq = output.seq();
        var app = NetOffice.ExcelApi.Application.GetActiveInstance();
        NetOffice.ExcelApi.Range sel = (NetOffice.ExcelApi.Range)app.Selection;

        var rawArray = sel.Value as Object[,];
        if (rawArray != null)
        {
            int a = rawArray.GetLowerBound(0);
            int b = rawArray.GetUpperBound(0);
            int c = rawArray.GetLowerBound(1);
            for (var i = a; i <= b; i++)
            {
                if (rawArray[i, c] != null)
                {
                    rawArray[i, c] = seq.first();
                    seq = seq.next();
                }
            }
            sel.Value = rawArray;
        }
        else
        {
            sel.Value = seq.first();
        }
    }