[pure-lang-svn] SF.net SVN: pure-lang: [146] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-27 19:18:03
|
Revision: 146 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=146&view=rev Author: agraef Date: 2008-05-27 12:17:52 -0700 (Tue, 27 May 2008) Log Message: ----------- Get rid of silly empty_list exceptions. Modified Paths: -------------- pure/trunk/lib/prelude.pure pure/trunk/test/prelude.log Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-27 18:13:58 UTC (rev 145) +++ pure/trunk/lib/prelude.pure 2008-05-27 19:17:52 UTC (rev 146) @@ -35,7 +35,6 @@ need to work from the end of a list towards its front. */ nullary out_of_bounds; // tuple or list index is out of bounds (!) -nullary empty_list; // empty list (head, tail, etc.) // bad_list_value xs; // not a proper list value (reverse, etc.) // xs denotes the offending tail of the list @@ -256,7 +255,6 @@ foldr1 f (x:xs) = foldr f x xs; head (x:xs) = x; -head [] = throw empty_list; init [x] = []; init (x:xs) = accum [x] xs with @@ -264,11 +262,9 @@ accum ys (x:xs) = accum (x:ys) xs; accum ys xs = reverse ys+init xs; end; -init [] = throw empty_list; last [x] = x; last (x:xs) = last xs; -last [] = throw empty_list; map f [] = []; map f (x:xs) = accum [f x] xs with @@ -307,7 +303,6 @@ end; tail (x:xs) = xs; -tail [] = throw empty_list; take n::int [] = []; take n::int (x:xs) Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-27 18:13:58 UTC (rev 145) +++ pure/trunk/test/prelude.log 2008-05-27 19:17:52 UTC (rev 146) @@ -708,7 +708,6 @@ foldr1 f/*0:01*/ [x/*0:101*/] = x/*0:101*/; foldr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldr f/*0:01*/ x/*0:101*/ xs/*0:11*/; head (x/*0:101*/:xs/*0:11*/) = x/*0:101*/; -head [] = throw empty_list; init [x/*0:101*/] = []; init (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+init xs/*0:1*/ { rule #0: accum ys [] = reverse ys @@ -742,10 +741,8 @@ <var> state 13 state 13: #1 #2 } end; -init [] = throw empty_list; last [x/*0:101*/] = x/*0:101*/; last (x/*0:101*/:xs/*0:11*/) = last xs/*0:11*/; -last [] = throw empty_list; map f/*0:01*/ [] = []; map f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [f/*0:01*/ x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (f/*1:01*/ x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+map f/*1:01*/ xs/*0:1*/ { rule #0: accum ys [] = reverse ys @@ -891,7 +888,6 @@ state 1: #0 } end; tail (x/*0:101*/:xs/*0:11*/) = xs/*0:11*/; -tail [] = throw empty_list; take n/*0:01*/::int [] = []; take n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*0*/ n/*0:01*/ [] (x/*0:101*/:xs/*0:11*/) with accum _/*0:001*/ ys/*0:01*/ [] = reverse ys/*0:01*/; accum n/*0:001*/::int ys/*0:01*/ _/*0:1*/ = reverse ys/*0:01*/ if n/*0:001*/<=0; accum n/*0:001*/::int ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (n/*0:001*/-1) (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum n/*0:001*/ ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+take n/*0:001*/ xs/*0:1*/ { rule #0: accum _ ys [] = reverse ys This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |