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
| import fs2.Stream | |
| import zio.interop.catz._ | |
| import zio.{ Runtime, Task } | |
| object FS2TaskInterop extends App { | |
| val runtime = Runtime.default | |
| val nonStream = Task(123).map(_ => BigDecimal("16:19:25.242056065Z")) | |
| val stream = Stream.eval(nonStream) |
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
| import cats.effect.{ ExitCode, IO, IOApp } | |
| import tsec.cipher.symmetric.{ AAD, AADEncryptor, IvGen } | |
| import tsec.cipher.symmetric.jca.{ AES256GCM, SecretKey } | |
| import tsec.common._ | |
| import tsec.cipher.symmetric._ | |
| object CryptoApp extends IOApp { | |
| private val aad: AAD = AAD("KnQCxy4rW4KuxMRcvkVvAs9KufF7XR4b".utf8Bytes) |
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
| import cats.data._ | |
| import cats.effect.ExitCode | |
| import cats.implicits._ | |
| import cats.~> | |
| import org.http4s.dsl.Http4sDsl2 | |
| import org.http4s.server.blaze.BlazeServerBuilder | |
| import org.http4s.{ Http, Request, Response } | |
| import zio._ | |
| import zio.clock.Clock | |
| import zio.interop.catz._ |
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
| defmodule BatailleRoyale do | |
| @cards 0..7 |> Enum.to_list |> List.duplicate(4) |> List.flatten | |
| def times(n) do | |
| results = | |
| 1..n | |
| |> Enum.map(fn _ -> play() end) | |
| |> Enum.map(fn {_, _, moves} -> moves end) |
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
| import java.util.NoSuchElementException | |
| import cats._ | |
| import cats.implicits._ | |
| import scala.annotation.tailrec | |
| object Max extends App { | |
| def maximum[A : Order](list: List[A]): A = list match { |
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
| module Repdigit where | |
| -- https://oeis.org/A010785 | |
| repdigit :: Integer -> Integer | |
| repdigit n = (n - 9 * floor ((fromInteger n - 1) / 9)) * (10 ^ floor ((fromInteger n + 8) / 9) - 1) `quot` 9 | |
| repdigits :: [Integer] | |
| repdigits = go 0 | |
| where go n = repdigit n : go (n + 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
| {-# LANGUAGE ParallelListComp #-} | |
| module FizzBuzz where | |
| -- https://en.wikipedia.org/wiki/Fizz_buzz | |
| fizzBuzz :: [String] | |
| fizzBuzz = take 100 $ go 1 | |
| where go n | |
| | n `mod` 15 == 0 = "fizzbuzz" : go (n + 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
| module LeftPad where | |
| leftPad :: Int -> Char -> String -> String | |
| leftPad n c x | |
| | n > length x = leftPad n c (c : x) | |
| | otherwise = x |
NewerOlder