[Swift-commit] r5223 - in www/presentations/OSCER_2011: . examples

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Wed Oct 12 13:44:37 CDT 2011


Author: wozniak
Date: 2011-10-12 13:44:37 -0500 (Wed, 12 Oct 2011)
New Revision: 5223

Added:
   www/presentations/OSCER_2011/examples/
   www/presentations/OSCER_2011/examples/01-app.swift
   www/presentations/OSCER_2011/examples/02-function.swift
   www/presentations/OSCER_2011/examples/03-wrapper.swift
   www/presentations/OSCER_2011/examples/04-arrays.swift
   www/presentations/OSCER_2011/examples/05-regexp.swift
   www/presentations/OSCER_2011/examples/06-filesys.swift
   www/presentations/OSCER_2011/examples/agenda.txt
   www/presentations/OSCER_2011/examples/annotate.sh
   www/presentations/OSCER_2011/examples/clean.sh
   www/presentations/OSCER_2011/examples/franklin.jpg
   www/presentations/OSCER_2011/examples/input.txt
   www/presentations/OSCER_2011/examples/input0.txt
   www/presentations/OSCER_2011/examples/input1.txt
   www/presentations/OSCER_2011/examples/input2.txt
   www/presentations/OSCER_2011/examples/script1.sh
   www/presentations/OSCER_2011/examples/script2.sh
Removed:
   www/presentations/OSCER_2011/oscer-examples.tgz
Log:
Check in scripts; drop TGZ


Added: www/presentations/OSCER_2011/examples/01-app.swift
===================================================================
--- www/presentations/OSCER_2011/examples/01-app.swift	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/01-app.swift	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,12 @@
+
+type file;
+
+app (file o) copy (file i)
+{
+  cp @i @o;
+}
+
+file input<"input.txt">;
+file output<"output.txt"> = copy(input);
+
+// Lines may be reversed

Added: www/presentations/OSCER_2011/examples/02-function.swift
===================================================================
--- www/presentations/OSCER_2011/examples/02-function.swift	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/02-function.swift	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,19 @@
+
+type file;
+
+app (file o) copy(file i)
+{
+  cp @i @o;
+}
+
+(string name) makeFileName()
+{
+  name = @strcat("input", ".txt");
+  tracef("FILENAME: %s\n", name);
+}
+
+string s = makeFileName();
+
+file input<single_file_mapper;file=s>;
+file output<"output.txt"> = copy(input);
+

Added: www/presentations/OSCER_2011/examples/03-wrapper.swift
===================================================================
--- www/presentations/OSCER_2011/examples/03-wrapper.swift	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/03-wrapper.swift	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,14 @@
+
+type file;
+
+app (file o1, file o2, file log) script(file i1, file i2)
+{
+  script1 @i1 @i2 @o1 @o2 stdout=@log;
+}
+
+file input1<"input1.txt">;
+file input2<"input2.txt">;
+file output1<"output1.txt">;
+file output2<"output2.txt">;
+file log<"log.txt">;
+(output1, output2, log) = script(input1, input2);

Added: www/presentations/OSCER_2011/examples/04-arrays.swift
===================================================================
--- www/presentations/OSCER_2011/examples/04-arrays.swift	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/04-arrays.swift	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,30 @@
+
+type file;
+
+app (file o, file log) script(file i[])
+{
+  script2 @filenames(i) @o stdout=@log;
+}
+
+(file result) noop()
+{}
+
+(string result[]) makeFilenames()
+{
+  foreach i in [0:1]
+  {
+    string s = @strcat("input", i, ".txt");
+    result[i] = s;
+  }
+}
+
+string a[] = makeFilenames();
+file input[]<array_mapper;files=a>;
+foreach f, i in a
+{
+  tracef("FILENAME: %s\n", f);
+}
+
+file output<"output.txt">;
+file log<"log.txt">;
+(output, log) = script(input);

Added: www/presentations/OSCER_2011/examples/05-regexp.swift
===================================================================
--- www/presentations/OSCER_2011/examples/05-regexp.swift	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/05-regexp.swift	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,32 @@
+
+type file;
+
+app (file o) convert (file i)
+{
+  convert @i @o;
+}
+
+app (file o) rotate(int d, file i)
+{
+  convert "-rotate" d @i @o;
+}
+
+file franklin_jpg<"franklin.jpg">;
+file franklin_png<regexp_mapper;
+                  source=@filename(franklin_jpg),
+                  match="(.*).jpg",
+                  transform="\\1-0.png">;
+
+tracef("JPG: %M\n", franklin_jpg);
+tracef("PNG: %M\n", franklin_png);
+
+franklin_png = convert(franklin_jpg);
+
+foreach i in [1:5]
+{
+  int d = i*60;
+  string s = @strcat("franklin-", d, ".png");
+  tracef("ROTATE: %s\n", s);
+  file f<single_file_mapper;file=s> = rotate(d, franklin_png);
+}
+

Added: www/presentations/OSCER_2011/examples/06-filesys.swift
===================================================================
--- www/presentations/OSCER_2011/examples/06-filesys.swift	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/06-filesys.swift	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,44 @@
+
+type file;
+
+app (file o) annotate(int d, file i)
+{
+  annotate @i d @o;
+}
+
+app (file o) makelog(int d, file i)
+{
+  echo "degrees:" d stdout=@o;
+}
+
+file franklin_pngs[]<filesys_mapper;
+                     prefix="franklin",
+                     suffix=".png">;
+
+file franklin_notes[]<structured_regexp_mapper;
+                      source=franklin_pngs,
+                      match="(.*).png",
+                      transform="\\1-note.png">;
+
+file franklin_logs[]<structured_regexp_mapper;
+                     source=franklin_notes,
+                     match="(.*)-note.png",
+                     transform="\\1.txt">;
+
+foreach f,i in franklin_pngs
+{
+  tracef("ANNOTATE: %M -> %M\n", franklin_pngs[i], franklin_notes[i]);
+  string s = @filename(f);
+  string n = @strcut(s, "franklin-(.*).png");
+  int d = @toint(n);
+  franklin_notes[i] = annotate(d, franklin_pngs[i]);
+}
+
+foreach p,j in franklin_notes
+{
+  tracef("LOG: %M -> %M\n", franklin_notes[j], franklin_logs[j]);
+  string s = @filename(p);
+  string n = @strcut(s, "franklin-(.*)-note.png");
+  int d = @toint(n);
+  franklin_logs[j] = makelog(d, franklin_notes[j]);
+}

Added: www/presentations/OSCER_2011/examples/agenda.txt
===================================================================
--- www/presentations/OSCER_2011/examples/agenda.txt	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/agenda.txt	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,23 @@
+
+01
+   basic script elements
+   how to run
+   demonstrate re-ordering
+
+02
+   functions
+   strcat - built-in functions
+   (arithmetic)
+
+03
+   demonstrate tc file
+   demonstrate stdout logging
+
+04
+   demonstrate arrays, foreach
+
+05
+   demonstrate regexp
+
+06
+   demonstrate producer-consumer, concurrency

Added: www/presentations/OSCER_2011/examples/annotate.sh
===================================================================
--- www/presentations/OSCER_2011/examples/annotate.sh	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/annotate.sh	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -x
+
+date "+%m/%d/%Y %I:%M%p"
+
+{
+  INPUT=$1
+  DEGREES=$2
+  OUTPUT=$3
+
+  sleep $(( $DEGREES / 60 ))
+
+  convert $INPUT       \
+    -stroke "#000C"    \
+    -pointsize 24      \
+    -gravity northwest \
+    -fill blue         \
+    -annotate +20+20 $DEGREES $OUTPUT || exit 1
+} 2>&1
+
+exit 0


Property changes on: www/presentations/OSCER_2011/examples/annotate.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: www/presentations/OSCER_2011/examples/clean.sh
===================================================================
--- www/presentations/OSCER_2011/examples/clean.sh	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/clean.sh	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+rm -rfv *.log *.rlog *.kml *.xml *.d
+rm -fv output*.txt log*.txt
+rm -fv franklin*.png franklin*.txt


Property changes on: www/presentations/OSCER_2011/examples/clean.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: www/presentations/OSCER_2011/examples/franklin.jpg
===================================================================
(Binary files differ)


Property changes on: www/presentations/OSCER_2011/examples/franklin.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: www/presentations/OSCER_2011/examples/input.txt
===================================================================
Added: www/presentations/OSCER_2011/examples/input0.txt
===================================================================
Added: www/presentations/OSCER_2011/examples/input1.txt
===================================================================
Added: www/presentations/OSCER_2011/examples/input2.txt
===================================================================
--- www/presentations/OSCER_2011/examples/input2.txt	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/input2.txt	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1 @@
+DATA2

Added: www/presentations/OSCER_2011/examples/script1.sh
===================================================================
--- www/presentations/OSCER_2011/examples/script1.sh	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/script1.sh	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -x
+
+date "+%m/%d/%Y %I:%M%p"
+
+{
+  INPUT1=$1
+  INPUT2=$2
+  OUTPUT1=$3
+  OUTPUT2=$4
+
+  cat $INPUT1 $INPUT2 || exit 1
+
+  touch $OUTPUT1 $OUTPUT2 || exit 1
+} 2>&1
+
+exit 0


Property changes on: www/presentations/OSCER_2011/examples/script1.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: www/presentations/OSCER_2011/examples/script2.sh
===================================================================
--- www/presentations/OSCER_2011/examples/script2.sh	                        (rev 0)
+++ www/presentations/OSCER_2011/examples/script2.sh	2011-10-12 18:44:37 UTC (rev 5223)
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+echo "COMMAND: $0 $*"
+
+set -x
+
+date "+%m/%d/%Y %I:%M%p"
+
+{
+  INPUT1=$1
+  INPUT2=$2
+  OUTPUT=$3
+
+  cat $INPUT1 $INPUT2 || exit 1
+
+  touch $OUTPUT || exit 1
+} 2>&1
+
+exit 0


Property changes on: www/presentations/OSCER_2011/examples/script2.sh
___________________________________________________________________
Added: svn:executable
   + *

Deleted: www/presentations/OSCER_2011/oscer-examples.tgz
===================================================================
(Binary files differ)




More information about the Swift-commit mailing list