Some interesting things to come. Totatlly not a lie and I’m totally not tipsy right now.
Once I figure out this “git” thing the kids are talking about, I’ll start posting my futile attempts to turn C# into a functional language.
This site was built on sacred ground.
Some interesting things to come. Totatlly not a lie and I’m totally not tipsy right now.
Once I figure out this “git” thing the kids are talking about, I’ll start posting my futile attempts to turn C# into a functional language.
No idea why I did this…
(define (fizzbuzz listIn [currentList empty]) (define (showWhich itemToTell) (let ([testString (string-append (if (= (modulo itemToTell 3) 0) "Fizz" "") (if (= (modulo itemToTell 5) 0) "Buzz" ""))]) (if (= (string-length testString) 0) itemToTell testString))) (define (add-head-to-list itemList listTAddTo) (append listTAddTo (list (showWhich (first itemList) )))) (cond [(null? listIn) currentList] [(null? (rest listIn)) (add-head-to-list listIn currentList)] [else (fizzbuzz (rest listIn) (add-head-to-list listIn currentList))]))
A quick example of how to use the Aggregate method to create a string of delimited members, or in this case characters. You might wonder why this example, or at least you should. It’s true, the character list to delimited string is pretty useless, but some idiot from where I work needed it.
[TestMethod] public void GetStringFromCharacters() { var charList = Enumerable.Range(0, 10).Select(x => 'a').ToList(); charList .Aggregate("", (inner, outer) => inner + outer.ToString() + ",") .Should() .Be("a,a,a,a,a,a,a,a,a,a"); }
The big thing here is the “” in the Aggregate method signature. That basically says that Inner is a string. If I didn’t have that specified, both inner and outer would be a character.
YAY