public static FuncList <T> ToFuncList <T>(this IEnumerable <T> seq)
        {
            FuncList <T> ret = FuncListExtensions.Empty <T>();

            foreach (var el in seq.Reverse())
            {
                ret = FuncListExtensions.Cons(el, ret);
            }
            return(ret);
        }
        public override TranslationState VisitTitledPart(TitledPart part, TranslationState ctx)
        {
            var rc           = new RectangleF(ctx.Rect.Left, ctx.Rect.Top + 35.0f, ctx.Rect.Width, ctx.Rect.Height - 35.0f);
            var bodyElements = part.Body.Accept(this, new TranslationState {
                Rect = rc
            }).Result;
            var titleRc = new RectangleF(ctx.Rect.Left, ctx.Rect.Top, ctx.Rect.Width, 35.0f);

            ctx.Result = FuncListExtensions.Cons(new TextElement(part.Text, titleRc), bodyElements);
            return(ctx);
        }
 private static FuncList <R> SelectUtil <T, R>(this FuncList <T> source, int i, Func <T, int, R> f)
 {
     if (source.IsEmpty)
     {
         return(FuncListExtensions.Empty <R>());
     }
     else
     {
         return(FuncListExtensions.Cons(f(source.Head, i), SelectUtil(source.Tail, i + 1, f)));
     }
 }
 public static FuncList <R> Select <T, R>(this FuncList <T> source, Func <T, R> f)
 {
     if (source.IsEmpty)
     {
         return(FuncListExtensions.Empty <R>());
     }
     else
     {
         return(FuncListExtensions.Cons(f(source.Head), Select(source.Tail, f)));
     }
 }
        public static FuncList <T> Concat <T>(this FuncList <FuncList <T> > concat)
        {
            var      el       = concat;
            List <T> elements = new List <T>();

            while (!el.IsEmpty)
            {
                var nested = el.Head;
                while (!nested.IsEmpty)
                {
                    elements.Add(nested.Head);
                    nested = nested.Tail;
                }
                el = el.Tail;
            }

            FuncList <T> ret = FuncListExtensions.Empty <T>();

            for (int i = 0; i < elements.Count; i++)
            {
                ret = FuncListExtensions.Cons(elements[i], ret);
            }
            return(ret);
        }
 public override TranslationState VisitImagePart(ImagePart part, TranslationState ctx)
 {
     ctx.Result = FuncListExtensions.Cons(new ImageElement(part.Url, ctx.Rect),
                                          FuncListExtensions.Empty <ScreenElement>());
     return(ctx);
 }
 public override TranslationState VisitTextPart(TextPart part, TranslationState ctx)
 {
     ctx.Result = FuncListExtensions.Cons(new TextElement(part.Text, ctx.Rect),
                                          FuncListExtensions.Empty <ScreenElement>());
     return(ctx);
 }