From 0029a9805ff2b9e13ff9e8a50268931554298b67 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Wed, 2 Sep 2020 09:15:00 -0800 Subject: [PATCH] Problem 5 --- problem5.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 problem5.go diff --git a/problem5.go b/problem5.go new file mode 100644 index 0000000..bbffead --- /dev/null +++ b/problem5.go @@ -0,0 +1,28 @@ +package main + +import "log" + +func cons(a, b int) func(func(int, int) (int, int)) (int, int) { + return func(f func(int, int) (int, int)) (int, int) { + return f(a, b) + } +} + +func test(a, b int) (int, int) { + return a, b +} + +func cdr(f func(func(int, int) (int, int)) (int, int)) int { + _, b := f(test) + return b +} + +func car(f func(func(int, int) (int, int)) (int, int)) int { + a, _ := f(test) + return a +} + +func main() { + log.Println(car(cons(3, 4))) + log.Println(cdr(cons(3, 4))) +}