Hey guys, I'm trying to get my head around LINQ and FP, so forgive me if this is naive. I'm trying to do some string parsing using LINQ and mapping onto a function, so I need to split my string up into smaller strings.
I want to split the array up into smaller lists of two. Can I use a reduce (.Aggregate()) to do this? I was trying to work out how to apply the reduce to return a list but I wasn't having any luck.
What I want is:
myString.ToCharArray().Take(2)
Mapped onto every second element.I couldn't get around in my head how to reduce the list without applying the take to every single element, instead of every second one.
Concrete example.
given (1, 2, 3, 4, 5, 6)
I want ((1, 2), (3,4), (5, 6))
To clarify:
given "abcdef"
I want "ab", "cd", "ef"
Cheers for your help guys.