From 6a0d7f5c434c3564d0119befb6799fd77581050a Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Fri, 3 Jan 2025 11:01:20 -0800 Subject: Initial --- ch01_01.4-iii.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ch01_01.4-iii.hs (limited to 'ch01_01.4-iii.hs') diff --git a/ch01_01.4-iii.hs b/ch01_01.4-iii.hs new file mode 100644 index 0000000..78885aa --- /dev/null +++ b/ch01_01.4-iii.hs @@ -0,0 +1,14 @@ +-- Exercise 1.4-iii +-- Prove `(a * b)^c == a^c * b*c`. +func2Tup :: (c -> (a, b)) -> (c -> a, c -> b) +func2Tup f = (fst . f, snd . f) + +-- This version takes in a tuple of functions, which is equivalent to them +-- being separate arguments: +tup2Func :: (c -> a, c -> b) -> c -> (a, b) +tup2Func (f, g) v = (f v, g v) + +-- This version has the same signature as Sandy's version, and calls `curry` +-- against my tupled rendition above: +tup2Func' :: (c -> a) -> (c -> b) -> c -> (a, b) +tup2Func' = curry tup2Func -- cgit v1.2.1