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
val notifyCustomerSchema = Ftl.schema { | |
verb(::notifyCustomer) | |
connectors { | |
http { | |
routes("/notify", "/notify-customer") | |
formats(Format.JSON) | |
} | |
grpc() |
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 gigi.pizzeria | |
verb makePizza { | |
data { | |
in | |
Order(..) | |
out | |
Pizza(..) | |
} |
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
-- Djikstra's shunting yard algorithm to parse infix notation expressions | |
-- 3 + 4 - 1 => 3 4 1 - + | |
-- https://en.wikipedia.org/wiki/Shunting-yard_algorithm | |
import Data.List | |
precedence "(" = 1 | |
precedence ")" = 1 | |
precedence "+" = 2 | |
precedence "-" = 2 |
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
-- Largest interval algorithm. | |
-- "Compute the largest profit to be gained from a series of prices" | |
-- | |
profits smallest largest gains [] = gains | |
profits smallest largest gains (p:ps) | |
| p < smallest = profits p p (gains ++ [largest - smallest]) ps | |
| p > largest = profits smallest p (gains ++ [p - smallest]) ps | |
| otherwise = profits smallest largest gains ps |
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
-- Finds the intersection of two rectangles, returned as a rectangle. | |
-- | |
data Rect = Rect { x :: Int, | |
y :: Int, | |
width :: Int, | |
height :: Int | |
} | NoRect deriving Show | |
-- Returns the intersection rectangle or NoRect if they don't intersect |
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
-- Floyd's algorithm to detect a cycle in a linked list | |
-- Also called the "Tortoise & Hare" algorithm | |
-- This increments two pointers at different rates, if | |
-- the second laps the first, then we have a cycle. | |
cyclical pick = iterateList 0 1 pick | |
where | |
iterateList tortoise hare pick | |
| pick tortoise == -1 = False | |
| pick hare == -1 = False |
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
-- Intersect an arbitrary number of ordered lists | |
-- based on a problem by Alec Thomas | |
intersectTwo [] [] = [] | |
intersectTwo ls [] = [] | |
intersectTwo [] ls = [] | |
intersectTwo (x:xs) (y:ys) | |
| x == y = [x] ++ (intersectTwo xs ys) | |
| x > y = intersectTwo (x:xs) ys |
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
-- FizzBuzz: http://wiki.c2.com/?FizzBuzzTest | |
fizzbuzz x | |
| fizz x && buzz x = "FizzBuzz" | |
| fizz x = "Fizz" | |
| buzz x = "Buzz" | |
| otherwise = "" | |
where | |
fizz n = (n `mod` 3) == 0 | |
buzz n = (n `mod` 5) == 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
-- Using merge to efficiently intersect two lists | |
ages = [1, 2, 5, 6] | |
names = [1, 5, 6, 7, 8, 9] | |
addresses = [2, 3, 7, 9, 10] | |
siblings = [3, 5, 6, 9] | |
intersect [] [] = [] | |
intersect [] _ = [] | |
intersect _ [] = [] |
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
// Code generated by Wire protocol buffer compiler, do not edit. | |
// Source file: bar.proto at 5:1 | |
package com.squareup.foobar.protos.bar; | |
import com.squareup.wire.FieldEncoding; | |
import com.squareup.wire.Message; | |
import com.squareup.wire.ProtoAdapter; | |
import com.squareup.wire.ProtoReader; | |
import com.squareup.wire.ProtoWriter; | |
import java.io.IOException; |
NewerOlder