fake build -t all --env a=b --env c=d --env e=f
*** [Env ("a","b"); Env ("c","d"); Env ("e","f")]
var arr = new [] { 0, 2, 4, 6, 8, 10 }; | |
Func<int[], bool, Func<int, Tuple<bool, int>, bool>, bool> aggregate = | |
(a, b, fn) => a.Skip(2).Aggregate(Tuple.Create(b, a[1]), (res, i) => Tuple.Create(res.Item1 && fn(i, res), i)).Item1; | |
var diff = arr[1] - arr[0]; | |
var isA = aggregate(arr, true, (i, r) => i - r.Item2 == diff); | |
arr = new [] { 1, 2, 4, 8, 16, 32 }; | |
diff = arr[1] / arr[0]; |
private static readonly Regex rx = new Regex(@"(\d)(\D+)?"); | |
public static string QuestionsMarks(string str) { | |
var input = rx.Matches(str).Select(m => Tuple.Create(Int32.Parse(m.Groups[1].Value), m.Groups[2].Value)).ToList(); | |
return input | |
.Zip(input.Skip(1), Tuple.Create) | |
.Where(t => t.Item1.Item1 + t.Item2.Item1 == 10) | |
.DefaultIfEmpty(Tuple.Create(Tuple.Create(0, ""), Tuple.Create(0, ""))) | |
.All(t => t.Item1.Item2.Count(c => c == '?') == 3) | |
.ToString() |
private static readonly Regex rx = new Regex(@"\b(\w+)\b"); | |
public static string LongestWord(string sen) { | |
return rx.Matches(sen) | |
.Select(m => m.Groups[0].Value) | |
.Select(w => Tuple.Create(w, w.Length)) | |
.OrderByDescending(t => t.Item2) | |
.Select(t => t.Item1) | |
.FirstOrDefault(); | |
} |
var str = "The quick brown fox jumped over the lazy dog. Hello-world! wOrLd WorLd. The new order!"; | |
var words = | |
new Regex(@"\b([A-Z-]+)\b", RegexOptions.IgnoreCase) | |
.Matches(str) | |
.Select(m => m.Groups[0].Value.ToLower()) | |
.GroupBy(g => g) | |
.Select(g => KeyValuePair.Create(g.Key, g.Count())) | |
.OrderByDescending(kv => kv.Value) | |
.ToDictionary(kv => kv.Key, kv => kv.Value); |
open System | |
open FSharp.Control | |
[<EntryPoint>] | |
let main _ = | |
let rec receiver () = | |
asyncSeq { | |
yield async.Return "." | |
yield! receiver () |
open System | |
open System.Runtime.InteropServices | |
type X() = | |
static member Outist(x: string, y: int, [<Out>] z: string byref) = | |
z <- "tuO" | |
(y, x) | |
[<EntryPoint>] | |
let main argv = |
open System | |
open FSharp.Control | |
[<EntryPoint>] | |
let main _ = | |
let rnd = Random() | |
let workflows = | |
[| | |
for x in 1 .. 100 -> | |
async { |
open System | |
open BenchmarkDotNet.Attributes | |
open BenchmarkDotNet.Running | |
open BenchmarkDotNet.Jobs | |
open FSharp.Control.Tasks.V2 | |
[<SimpleJob(RuntimeMoniker.NetCoreApp31); MemoryDiagnoser>] | |
type Test() = | |
[<Params(100, 1000, 10000)>] |
open System | |
open System.Threading | |
open System.Threading.Channels | |
open FSharp.Control | |
let channel = | |
Channel.CreateUnbounded<int>(UnboundedChannelOptions(SingleWriter=true, SingleReader=true)) | |
let mutable cnt = 0 | |
let timerEvent _ = |
fake build -t all --env a=b --env c=d --env e=f
*** [Env ("a","b"); Env ("c","d"); Env ("e","f")]