Skip to content

Instantly share code, notes, and snippets.

@RyushiAok
RyushiAok / 🐲2024.fsx
Created January 1, 2024 15:01
🐲2024.fsx
open System
open System.Threading
type Frame = string[]
type Animation = seq<Frame>
let mergeFrame (a: Frame) (b: Frame) : Frame =
Array.zip a b
|> Array.map (fun (a, b) ->
(a.ToCharArray(), b.ToCharArray())
@RyushiAok
RyushiAok / FsFizzBuzz.fsx
Created December 5, 2023 03:43
FsFizzBuzz.fsx
let (|Fizz|_|) n = if n % 3 = 0 then Some "Fizz" else None
let (|Buzz|_|) n = if n % 5 = 0 then Some "Buzz" else None
let (|FizzBuzz|_|) n =
if n % 15 = 0 then Some "FizzBuzz" else None
let fizzBuzz =
function
| FizzBuzz fizzbuzz -> fizzbuzz
| Fizz fizz -> fizz
@RyushiAok
RyushiAok / markdown.fs
Created October 18, 2023 15:03
F# Markdown Builder
type Block =
| H1 of string
| H2 of string
| P of string
type Markdown = {
title: string
author: string
blocks: Block list
} with
@RyushiAok
RyushiAok / fix_ml_pipline.fs
Last active October 15, 2023 12:35
fix_ml_pipline
// fix: https://gist.github.com/jkone27/de477e362f3ee9f36069c0010e0a1f29
open Microsoft.ML
open Microsoft.ML.Data
open FSharp.Data
[<Literal>]
let trainDataPath = __SOURCE_DIRECTORY__ + "/house-price-train.csv"
[<Literal>]
@RyushiAok
RyushiAok / unko_builder.fs
Created October 9, 2023 12:56
uncode💩
type NextChar = NextChar
type NextWidth = NextWidth of char
type NextHeight = NextHeight of char * int
type EndUnnko = EndUnnko of char * int * int
type UnnkoBuilder () =
member _.Yield(_: unit) = NextChar
member _.Run(EndUnnko (char, w, h): EndUnnko) =
let nChars n c = c |> Array.replicate n |> System.String
printfn "%s∫ ∫ ∫ " <| nChars h ' '
printfn "%sノヽ " <| nChars h ' '