I believe 'concat' takes a sequence of sequences, whereas you are just passing it a sequence (perhaps of strings, which are themselves sequences of characters, which is probably not what you intend). So the two snippets are not the same unless you wrap the argument to concat in another one-element seq I think (don't have time to try right now).

By on 5/11/2009 9:59 AM ()

actually the Tokenizer is somewhat different from what I posted before. It is now a seqence of sequences (see the code below). From what I can figure out it looks like the concat includes in the final result only the first element of every sequence.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 

    type private Tokenizer (template:TextReader) =
        let mutable current: Token array = [||]
        
        interface IEnumerator<Token seq> with
            member this.Current = Seq.of_array current
        
        interface IEnumerator with
            member this.Current = Seq.of_array current :> obj
            member this.MoveNext() =
                if current.Length > 0 && current.[0] = Nothing then false
                else
                    let buffer = Array.create 4096 ' '
                    let count = template.ReadBlock(buffer, 0, buffer.Length)
                    if count = 0 then current <- [|Nothing|]
                    else 
                        let line = new String(buffer, 0, count)
                        let in_tag = ref true
                        current <- 
                            Array.map 
                                (fun (token:string) ->
                                    in_tag := not !in_tag
                                    if !in_tag then
                                        match token.[0..1] with
                                        | "{{" -> Variable (new VariableToken(token, 0, 0))
                                        | "{%" -> Block (new BlockToken(token, 0, 0))
                                        | "{#" -> Comment (new CommentToken(token, 0, 0))
                                        | _ -> Text (new TextToken(token, 0, 0))
                                    else
                                        Text(new TextToken(token, 0, 0))
                                 )
                                 (Constants.tag_re.Split(line))
                    true
                
            member this.Reset() = failwith "Reset is not supported by Tokenizer"
        
        interface IEnumerable<Token seq> with
            member this.GetEnumerator():IEnumerator<Token seq> =
                 this :> IEnumerator<Token seq>

        interface IEnumerable with
            member this.GetEnumerator():IEnumerator =
                this :> IEnumerator

        interface IDisposable with
            member this.Dispose() = ()
By on 5/11/2009 10:16 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper