From 56e68abc1d03f1991f45365b4adc5b0bc4f05996 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 24 Oct 2011 23:53:27 -0400 Subject: [PATCH] Add bang patterns for the cube_at function (Ben Lippmeier). --- src/Grid.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Grid.hs b/src/Grid.hs index ca66437..71e39a0 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE BangPatterns #-} -- | The Grid module just contains the Grid type and two constructors -- for it. We hide the main Grid constructor because we don't want -- to allow instantiation of a grid with h <= 0. @@ -65,7 +66,7 @@ make_grid grid_size values -- centered on that position. If there is no cube there (i.e. the -- position is outside of the grid), it will throw an error. cube_at :: Grid -> Int -> Int -> Int -> Cube -cube_at g i j k +cube_at !g !i !j !k | i < 0 = error "i < 0 in cube_at" | i >= xsize = error "i >= xsize in cube_at" | j < 0 = error "j < 0 in cube_at" -- 2.43.2