Skip to content

Instantly share code, notes, and snippets.

@OnurGumus
OnurGumus / Program.fs
Last active January 24, 2017 12:02
Fsharp Workshop 5
open System
module Async =
let map f workflow = async { let! res = workflow
return f res }
let bind f workflow = async.Bind(workflow, f)
let readInput() = async { return Console.ReadLine() }
let random() = async { return System.Random().Next(100) }
@OnurGumus
OnurGumus / Program.fs
Created January 24, 2017 15:56
FSharp type classes
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open System
module Async =
let map f workflow = async { let! res = workflow
return f res }
let bind f workflow = async.Bind(workflow, f)
type FMap = FMap with
@OnurGumus
OnurGumus / DroppingStages.cs
Created May 25, 2019 05:26
Some dummy prototype on how akka streams can drop elements
using Akka;
using Akka.Actor;
using Akka.Configuration;
using Akka.Streams;
using Akka.Streams.Dsl;
using Akka.Streams.Implementation;
using Akka.Streams.Implementation.Stages;
using Akka.Streams.Stage;
using System;
using System.Threading;
open System
#if FABLE_COMPILER
open Fable.Core
open Fable
[<Emit("prompt($0,'')")>]
let prompt (s1 : string ) : string = jsNative
@OnurGumus
OnurGumus / OldRazorClassLib.csproj
Created August 15, 2019 06:37
Old razor class lib template
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
open Fable
open Fable.Core
open Fable.Core.JS
let parityl( x : uint64 ) =
let mutable x = x
let mutable result : uint64 = uint64 0
while (x > uint64(0L)) do
result <- result + (x &&& uint64 1)
x <- (x >>> 1)
@OnurGumus
OnurGumus / Sedgewick_binary_tree.fs
Created September 27, 2019 10:50
Sedgewick binary tree
// Write code or load a sample from sidebar
open Fable
open Fable.Core
open Fable.Core.JS
[<AllowNullLiteralAttribute>]
type Node<'Key , 'Value when 'Key :> System.IComparable<'Key>>(key: 'Key, value : 'Value , N : int) =
member _.Key = key
member val Value = value with get, set
member val N = N with get, set
@OnurGumus
OnurGumus / kickstart.fs
Created September 28, 2019 15:03
Kickstart functional programming
open Fable
open Fable.Core
open Fable.Core.JS
open System
[<Emit("prompt($0,'')")>]
let prompt (s1 : string) : string = jsNative
let input = prompt("hello")
@OnurGumus
OnurGumus / kickstart_partial_application.fs
Created October 5, 2019 13:42
kick start week 2 partial application
let add x y = x + y
let inc = add 1
5 |> inc |> printf "%A"
printf "%A" <| inc 5
printf "%A" (inc 5)
@OnurGumus
OnurGumus / kickstart_functional_break.fs
Created October 5, 2019 14:05
kick start week 2 functional break
let mutable cont = true
let mutable init = 1001
while cont do
if init % 37 = 0 then
printf "%i" init
cont <- false
init <- init + 1