This file contains 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
(* | |
Rules - https://techcommunity.microsoft.com/t5/azure-developer-community-blog/it-s-2020-is-your-code-ready-for-leap-day/ba-p/1157279 | |
… Is the year evenly divisible by 4? Then it is a leap year. (Examples: 2012, 2016, 2020, 2024) | |
… Unless it is also evenly divisible by 100. Those are not leap years. (Examples: 1800, 1900, 2100) | |
… Except that year that are evenly divisible by 400 are leap years. (Examples: 1600, 2000, 2400) | |
*) | |
let fmod (x:int) (y:int) : bool = x % y = 0 | |
let isEvenlyDivisibleByFour (year:int) : bool = fmod year 4 | |
let isEvenlyDivisibleByOneHundred (year:int) : bool = fmod year 100 |
This file contains 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.Security.Cryptography | |
let getHashKey = | |
let hmac = new HMACSHA256() | |
printfn "%s" (Convert.ToBase64String(hmac.Key)) | |
getHashKey |
This file contains 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
#r @"C:\Shared Resources\ImageResizer\ImageResizer.4.2.5\lib\net45\ImageResizer.dll" | |
open ImageResizer | |
open System.IO | |
let sourceFolder = @"C:\images2resize" | |
let images = Directory.GetFiles(sourceFolder, "*.jpeg", SearchOption.AllDirectories) | |
let resizeImages = |
This file contains 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
let (|MultOf3|_|) i = if i % 3 = 0 then Some MultOf3 else None | |
let (|MultOf5|_|) i = if i % 5 = 0 then Some MultOf5 else None | |
let fizzBuzz i = | |
match i with | |
| MultOf3 & MultOf5 -> printf "FizzBuzz, " | |
| MultOf3 -> printf "Fizz, " | |
| MultOf5 -> printf "Buzz, " | |
| _ -> printf "%i, " i | |
This file contains 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
let numbers = [ 1..100 ] | |
let isDivisibleBy3 x = | |
match x % 3 with | |
| 0 -> true | |
| _ -> false | |
let isDivisibleBy5 x = | |
match x % 5 with | |
| 0 -> true |