This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* | |
| MIT License | |
| Copyright (c) 2024 Mårten Rånge | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| open System.Diagnostics | |
| open System.Text | |
| open System.Threading | |
| let inline fract x = x - floor x | |
| let rec mandelbrot (x : float) (y : float) (cx : float) (cy : float) i = | |
| if i > 0 then | |
| let x2 = x*x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gives an array of 3 elements | |
| IEnumerable<ulong> x0 = Enumerable.Concat<ulong>([1], Unbounded()); | |
| ulong[] y0 = x0.Take(3).ToArray(); | |
| // Crashes with out of memory after some time | |
| IEnumerable<ulong> x1 = [1, ..Unbounded()]; | |
| ulong[] y1 = x0.Take(3).ToArray(); | |
| IEnumerable<ulong> Unbounded() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var primes = SieveOfEratosthenes(100); | |
| var primes_ = string.Join(',', primes); | |
| Console.WriteLine(primes_); | |
| int[] SieveOfEratosthenes(int n) | |
| { | |
| bool[] noPrime = new bool[n]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| open System.Globalization | |
| open System.Windows | |
| open System.Windows.Media | |
| open System.Windows.Threading | |
| open FSharp.Core.Printf | |
| type CellSymbol = | |
| | Empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BPM =80 | |
| function v3(x,y,z) | |
| return {x,y,z} | |
| end | |
| model = { | |
| vertices = { | |
| v3(-1,-1,-1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clamp(value, min, max) | |
| return math.min(math.max(value, min), max) | |
| end | |
| function mix(a,b,x) | |
| return a+(b-a)*x | |
| end | |
| function pmin(a,b,k) | |
| local h = clamp(0.5+0.5*(b-a)/k, 0.0, 1.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace MyNamespace | |
| { | |
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Text.Json; | |
| using System.Text.Json.Serialization; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var repoRepos = new RepositoryRepository(); | |
| var pageRepo0 = repoRepos.GetRepository<IPage>(); | |
| var pageRepo1 = repoRepos.GetRepository<IPage>(); | |
| class RepositoryRepository | |
| { | |
| readonly List<IBaseRepository> _repos = new(); | |
| IBaseRepository CreateRepository(Type t) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Runtime.CompilerServices; | |
| // An "immutable" string | |
| var x = "I am immutable"; | |
| // *Insert evil laugh here* | |
| var y = Unsafe.As<char[]>(x); | |
| var z = "mutable!!"; | |
| // Overwriting the string | |
| // Might only "work" on x64 but for hackers 'Might' is good enough ;) |