Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text.RegularExpressions;
namespace Framework.Core.Com
{
static class ComWrapperExtension
using System;
using System.Runtime.InteropServices;
namespace Framework.Core.Com
{
/// <summary>
/// VARIANT: this is equivalent to "Object" in VB. It's the universal variable type for COM.
/// </summary>
/// <remarks>The "vt" flag determines which of the other fields have meaning. vt is a VarEnum.</remarks>
[StructLayout(LayoutKind.Explicit, Size = 16)]
let l = System.Collections.Generic.List<int>()
l.Add 1
printfn "%O" l // System.Collections.Generic.List`1[System.Int32]
printfn "%A" l // seq [1]
let wildcardMatch (pattern:string) (target:string) =
let rec wildcardMatch (pattern:char list) (target: char list) =
match pattern, target with
| '*'::('*'::_ as p) , _ -> wildcardMatch p target
| [], [] | ['*'], [] -> true
| [], _ | _, [] -> false
| '?'::p, _::t -> wildcardMatch p t
| x::p, y::t when x = y -> wildcardMatch p t
| '*'::x::p, y::t when x = y && t |> List.contains x |> not -> wildcardMatch p t
| '*'::_, _::t -> wildcardMatch pattern t
package main
import (
"fmt"
)
func coins(amount int) map[int]int {
coins := []int{25, 10, 5, 2, 1}
remaining := amount
let csv = """ID_Centrale;date;type;sstype;valeur
278;2022-02-10 16:00:00.0000000;EA;P;76128
278;2022-02-10 16:00:00.0000000;EA;HPH;154196
278;2022-02-10 16:00:00.0000000;EA;HCE;0
278;2022-02-10 16:00:00.0000000;EAP;P;44
278;2022-02-10 16:00:00.0000000;EAP;HPH;0
278;2022-02-10 16:00:00.0000000;EAP;HCH;0
278;2022-02-10 16:00:00.0000000;EAP;HPE;0
751;2022-02-15 14:00:00.0000000;;index1;44853
751;2022-02-15 14:00:00.0000000;;index2;405194
let csv = """ID_Centrale;date;type;sstype;valeur
278;2022-02-10 16:00:00.0000000;EA;P;76128
278;2022-02-10 16:00:00.0000000;EA;HPH;154196
278;2022-02-10 16:00:00.0000000;EA;HCE;0
278;2022-02-10 16:00:00.0000000;EAP;P;44
278;2022-02-10 16:00:00.0000000;EAP;HPH;0
278;2022-02-10 16:00:00.0000000;EAP;HCH;0
278;2022-02-10 16:00:00.0000000;EAP;HPE;0
751;2022-02-15 14:00:00.0000000;;index1;44853
module Recursive =
let convergesIn =
let rec convergesIn i previous f x =
match previous with
| Some p when p = f x -> i
| _ -> let y = f x in convergesIn (i + 1) (Some y) f y
convergesIn 0 None
module Functional =
#r "nuget:FSharp.Data"
#r "nuget:xplot.googlecharts"
module Snd =
let map f (x, y) = x, f y
open XPlot.GoogleCharts
open FSharp.Data
@cboudereau
cboudereau / main.go
Created July 7, 2021 09:57
golang defer/panic/recover
package main
import "fmt"
// Defer is a stack and pop each func
func main() {
defer func() {
fmt.Println("0")
if r := recover(); r != nil {