From: Michael Orlitzky Date: Thu, 28 Apr 2011 01:36:12 +0000 (-0400) Subject: Use the eta reduce in two Cube functions (hlint). X-Git-Tag: 0.0.1~363 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=f96b07dc2004d60bc87a7ff849959ad76fa7bc45;p=spline3.git Use the eta reduce in two Cube functions (hlint). Add comments to three Cube functions. --- diff --git a/src/Cube.hs b/src/Cube.hs index d0276c8..882233f 100644 --- a/src/Cube.hs +++ b/src/Cube.hs @@ -163,13 +163,24 @@ cube_at g i' j' k' -- These next three functions basically form a 'for' loop, looping -- through the xs, ys, and zs in that order. -cubes_from_values :: Grid -> Int -> Int -> [Double] -> [Cube] -cubes_from_values g i' j' vals = - zipWith (reverse_cube g i' j') [0..] vals - -cubes_from_planes :: Grid -> Int -> [[Double]] -> [[Cube]] -cubes_from_planes g i' planes = - zipWith (cubes_from_values g i') [0..] planes +-- | The cubes_from_values function will return a function that takes +-- a list of values and returns a list of cubes. It could just as +-- well be written to take the values as a parameter; the omission +-- of the last parameter is known as an eta reduce. +cubes_from_values :: Grid -> Int -> Int -> ([Double] -> [Cube]) +cubes_from_values g i' j' = + zipWith (reverse_cube g i' j') [0..] + +-- | The cubes_from_planes function will return a function that takes +-- a list of planes and returns a list of cubes. It could just as +-- well be written to take the planes as a parameter; the omission +-- of the last parameter is known as an eta reduce. +cubes_from_planes :: Grid -> Int -> ([[Double]] -> [[Cube]]) +cubes_from_planes g i' = + zipWith (cubes_from_values g i') [0..] + +-- | Takes a grid as an argument, and returns a three-dimensional list +-- of cubes centered on its grid points. cubes :: Grid -> [[[Cube]]] cubes g = zipWith (cubes_from_planes g) [0..] (function_values g)