changeset 179:64be565a40c6

Implement If method on List, fix Get Char to handle end of file, fix nested list pretty printing
author Mike Pavone <pavone@retrodev.com>
date Sat, 18 Jun 2011 11:11:58 -0700
parents ed322ae64738
children c40e0faa1c92
files list.rhope string.rhope
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/list.rhope	Wed Jun 15 01:18:28 2011 -0700
+++ b/list.rhope	Sat Jun 18 11:11:58 2011 -0700
@@ -354,7 +354,7 @@
 
 _String Seq[text,val,key:out]
 {
-	out <- [text]Append[ [[["\n\t"]Append[String[key]]]Append[":\t"]]Append[ [[String[val]]Split["\n"]]Join["\t\n"] ] ]
+	out <- [text]Append[ [[["\n\t"]Append[String[key]]]Append[":\t"]]Append[ [[String[val]]Split["\n"]]Join["\n\t"] ] ]
 }
 
 String@List Leaf[list:out]
@@ -378,6 +378,15 @@
 	{ out <- _Print Seq[list, [list]First] }
 }
 
+If@List Leaf[list:yep,nope]
+{
+	yep,nope <- If[[[list]Buffer >>]Length]
+}
+
+If@List[list:yep,nope]
+{
+	yep,nope <- If[[list]Length >>]
+}
 
 Peek@List[list:out,empty]
 {
--- a/string.rhope	Wed Jun 15 01:18:28 2011 -0700
+++ b/string.rhope	Sat Jun 18 11:11:58 2011 -0700
@@ -106,11 +106,12 @@
 	{ out <- write[1i32, [Array[]]Append[10u8], 1i64] }
 }
 
-Get Char[:out]
+Get Char[:out,err]
 {
-	read[0, [Array[]]Set[0, 0u8], 1i64]
-	{}
-	{ out <- String[~] }
+	ret,data <- read[0, [Array[]]Set[0, 0u8], 1i64]
+	If[[ret]<[1i64]]
+	{ err <- Val[ret] }
+	{ out <- String[data] }
 }
 
 _String to Int[current,index,array,ten,conv:out]