[pure-lang-svn] SF.net SVN: pure-lang: [323] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-06-27 19:20:04
|
Revision: 323 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=323&view=rev Author: agraef Date: 2008-06-27 12:20:13 -0700 (Fri, 27 Jun 2008) Log Message: ----------- Rename the slicing operator to 'svn diff'. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lib/prelude.pure pure/trunk/test/prelude.log Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-27 18:44:55 UTC (rev 322) +++ pure/trunk/ChangeLog 2008-06-27 19:20:13 UTC (rev 323) @@ -1,5 +1,9 @@ 2008-06-27 Albert Graef <Dr....@t-...> + * lib/prelude.pure: Using xs!ns for slicing conflicts with more + general indexing of containers with arbitrary keys. Use !! for + slicing instead. Reported by Jiri Spitz. + * runtime.cc/h: Added pure_current_interp(), variable and constant definitions, management of temporary definition levels. Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-06-27 18:44:55 UTC (rev 322) +++ pure/trunk/lib/prelude.pure 2008-06-27 19:20:13 UTC (rev 323) @@ -59,7 +59,7 @@ prefix 7 ~ ; // bitwise not infixr 8 ^ ; // exponentiation prefix 8 # ; // size operator -infixl 9 ! ; // indexing +infixl 9 ! !! ; // indexing, slicing infixr 9 . ; // function composition /* Pull in the primitives (arithmetic etc.) and the standard string functions. @@ -185,19 +185,19 @@ accum ys xs = ys,xs; end; -/* Slicing. xs!ns returns the list of xs!n for all members n of the index list - ns which are in the range 0..#xs-1. This works on any data structure with - zero-based indices and thus, in particular, on the list and tuple +/* Slicing. xs!!ns returns the list of xs!n for all members n of the index + list ns which are in the range 0..#xs-1. This works on any data structure + with zero-based indices and thus, in particular, on the list and tuple structures defined above. */ -xs![] = []; -xs!(n:ns) = accum [] (n:ns) with +xs!![] = []; +xs!!(n:ns) = accum [] (n:ns) with accum ys [] = reverse ys; accum ys (n::int:ns) = accum (xs!n:ys) ns if n>=0 && n<m; = accum ys ns otherwise; accum ys (n:ns) = accum (xs!n:ys) ns if n>=0 && n<m; = accum ys ns otherwise; - accum ys ns = reverse ys+xs!ns; + accum ys ns = reverse ys+xs!!ns; end when m::int = #xs end; /* Arithmetic sequences. */ Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-06-27 18:44:55 UTC (rev 322) +++ pure/trunk/test/prelude.log 2008-06-27 19:20:13 UTC (rev 323) @@ -591,14 +591,14 @@ state 12: #0 #2 state 13: #1 #2 } end; -xs/*0:01*/![] = []; -xs/*0:01*/!(n/*0:101*/:ns/*0:11*/) = accum/*0*/ [] (n/*1:101*/:ns/*1:11*/) with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum ys/*0:01*/ (n/*0:101*/:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum ys/*0:01*/ ns/*0:1*/ = reverse ys/*0:01*/+xs/*2:01*/!ns/*0:1*/ { +xs/*0:01*/!![] = []; +xs/*0:01*/!!(n/*0:101*/:ns/*0:11*/) = accum/*0*/ [] (n/*1:101*/:ns/*1:11*/) with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum ys/*0:01*/ (n/*0:101*/:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum ys/*0:01*/ ns/*0:1*/ = reverse ys/*0:01*/+xs/*2:01*/!!ns/*0:1*/ { rule #0: accum ys [] = reverse ys rule #1: accum ys (n::int:ns) = accum (xs!n:ys) ns if n>=0&&n<m rule #2: accum ys (n::int:ns) = accum ys ns rule #3: accum ys (n:ns) = accum (xs!n:ys) ns if n>=0&&n<m rule #4: accum ys (n:ns) = accum ys ns - rule #5: accum ys ns = reverse ys+xs!ns + rule #5: accum ys ns = reverse ys+xs!!ns state 0: #0 #1 #2 #3 #4 #5 <var> state 1 state 1: #0 #1 #2 #3 #4 #5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |