[Swift-commit] r3338 - trunk/examples

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon May 31 05:57:08 CDT 2010


Author: davidk
Date: 2010-05-31 05:57:08 -0500 (Mon, 31 May 2010)
New Revision: 3338

Added:
   trunk/examples/if.swift
   trunk/examples/iterate.swift
   trunk/examples/one.txt
   trunk/examples/q21.swift
   trunk/examples/q3.swift
   trunk/examples/q5.swift
   trunk/examples/q6.swift
   trunk/examples/q7.swift
   trunk/examples/q8.swift
   trunk/examples/restart.swift
   trunk/examples/second_procedure.swift
   trunk/examples/three.txt
   trunk/examples/two.txt
   trunk/examples/wcl
Removed:
   trunk/examples/tutorial/
Log:
Further modifications, updates and changes to tutorial scripts


Added: trunk/examples/if.swift
===================================================================
--- trunk/examples/if.swift	                        (rev 0)
+++ trunk/examples/if.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,18 @@
+type messagefile {}
+
+(messagefile t) greeting (string s) {
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+messagefile outfile <"hello20.txt">;
+
+boolean morning = true;
+
+if(morning) {
+  outfile = greeting("good morning");
+} else {
+  outfile = greeting("good afternoon");
+}
+

Added: trunk/examples/iterate.swift
===================================================================
--- trunk/examples/iterate.swift	                        (rev 0)
+++ trunk/examples/iterate.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,22 @@
+type counterfile;  
+  
+(counterfile t) echo(string m) {   
+  app {  
+    echo m stdout=@filename(t);  
+  }  
+}  
+  
+(counterfile t) countstep(counterfile i) {  
+  app {  
+    wcl @filename(i) @filename(t);  
+  }  
+}  
+  
+counterfile a[]  <simple_mapper;prefix="foldout">;  
+  
+a[0] = echo("793578934574893");  
+  
+iterate v {  
+  a[v+1] = countstep(a[v]);  
+ trace("extract int value ", at extractint(a[v+1]));  
+} until (@extractint(a[v+1]) <= 1);  

Added: trunk/examples/one.txt
===================================================================
--- trunk/examples/one.txt	                        (rev 0)
+++ trunk/examples/one.txt	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1 @@
+this is one.txt

Added: trunk/examples/q21.swift
===================================================================
--- trunk/examples/q21.swift	                        (rev 0)
+++ trunk/examples/q21.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,14 @@
+type messagefile {} 
+
+(messagefile t) greeting (string s="hello") {   
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+messagefile english <"english2.txt">;
+messagefile french <"francais2.txt">;
+
+english = greeting();
+french = greeting(s="bonjour");
+

Added: trunk/examples/q3.swift
===================================================================
--- trunk/examples/q3.swift	                        (rev 0)
+++ trunk/examples/q3.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,10 @@
+type file {} 
+
+(file t) echo (string s = "default greeting") {   
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+file hw = echo();
+

Added: trunk/examples/q5.swift
===================================================================
--- trunk/examples/q5.swift	                        (rev 0)
+++ trunk/examples/q5.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,14 @@
+type messagefile; 
+
+(messagefile t) greeting (string s[]) {   
+    app {
+        echo s[0] s[1] s[2] stdout=@filename(t);
+    }
+}
+
+messagefile outfile <"q5out.txt">;
+
+string words[] = ["how","are","you"];
+
+outfile = greeting(words);
+

Added: trunk/examples/q6.swift
===================================================================
--- trunk/examples/q6.swift	                        (rev 0)
+++ trunk/examples/q6.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,14 @@
+type file {} 
+
+(file t) echo (string s) {   
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+string greetings[] = ["how","are","you"];
+
+foreach g in greetings {
+  file hw = echo(g);
+}
+

Added: trunk/examples/q7.swift
===================================================================
--- trunk/examples/q7.swift	                        (rev 0)
+++ trunk/examples/q7.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,16 @@
+type file {} 
+
+(file t) echo (string s) {   
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+string outputNames = "one two three";
+
+file outputFiles[] <fixed_array_mapper;files=outputNames>;
+
+foreach f in outputFiles {
+    f = echo("hello");
+}
+

Added: trunk/examples/q8.swift
===================================================================
--- trunk/examples/q8.swift	                        (rev 0)
+++ trunk/examples/q8.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,14 @@
+
+type file {} 
+
+(file t) echo (string s) {   
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+file inputFiles[] <filesys_mapper;pattern="*">;
+
+file o <"foo.out">;
+o = echo(@filenames(inputFiles));
+

Added: trunk/examples/restart.swift
===================================================================
--- trunk/examples/restart.swift	                        (rev 0)
+++ trunk/examples/restart.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,32 @@
+type file;  
+  
+(file f) touch() {  
+  app {  
+    touch @f;  
+  }  
+}  
+  
+(file f) processL(file inp) {  
+  app {  
+    echo "processL" stdout=@f;  
+  }  
+}  
+  
+(file f) processR(file inp) {  
+  app {  
+    broken "process" stdout=@f;  
+  }  
+}  
+  
+(file f) join(file left, file right) {  
+  app {   
+    echo "join" @left @right stdout=@f;  
+  }   
+}  
+  
+file f = touch();  
+  
+file g = processL(f);  
+file h = processR(f);  
+  
+file i = join(g,h);  

Added: trunk/examples/second_procedure.swift
===================================================================
--- trunk/examples/second_procedure.swift	                        (rev 0)
+++ trunk/examples/second_procedure.swift	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,20 @@
+type messagefile {} 
+
+(messagefile t) greeting (string s) {   
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+(messagefile o) capitalise(messagefile i) {   
+    app {
+        tr "[a-z]" "[A-Z]" stdin=@filename(i) stdout=@filename(o);
+    }
+}
+
+messagefile hellofile <"hello.txt">;
+messagefile final <"capitals.txt">;
+
+hellofile = greeting("hello from Swift");
+final = capitalise(hellofile);
+

Added: trunk/examples/three.txt
===================================================================
--- trunk/examples/three.txt	                        (rev 0)
+++ trunk/examples/three.txt	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1 @@
+three

Added: trunk/examples/two.txt
===================================================================
--- trunk/examples/two.txt	                        (rev 0)
+++ trunk/examples/two.txt	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1 @@
+a second file

Added: trunk/examples/wcl
===================================================================
--- trunk/examples/wcl	                        (rev 0)
+++ trunk/examples/wcl	2010-05-31 10:57:08 UTC (rev 3338)
@@ -0,0 +1,3 @@
+#!/bin/bash
+echo -n $(wc -c < $1) > $2
+


Property changes on: trunk/examples/wcl
___________________________________________________________________
Name: svn:executable
   + *




More information about the Swift-commit mailing list