[split-points.pcl
strick**20111008041855
 Ignore-this: 6a24a89890b5cc67eb706de6c854aa24
] addfile ./split-points.pcl
addfile ./split-points.sh
hunk ./repl.hs 9
+import qualified System.Environment
hunk ./repl.hs 18
-  lines <- getContents
+  args <- System.Environment.getArgs
+  let argv = if length args > 0 then tail args else []
+  lines <- if length args > 0 then readFile $ head $ args else getContents
hunk ./repl.hs 22
-  (result, terp) <- runStateT (Tcl.evalProcBody [] lines []) Tcl.freshTerp
+  (result, terp) <- runStateT (
+      Tcl.evalProcBody ["argv"] lines [Tcl.joinTclList argv]
+          ) Tcl.freshTerp
hunk ./split-points.pcl 1
+# Pick split points for $1 parts from first words of stdin.
+
+set n 0
+while {>= [gets stdin line] 0} {
+  set row($n) [lindex [split $line] 0]
+  incr n
+}
+puts "n=$n"
+
+for {set i 1} {$i < $argv} {incr i} {
+  set x [expr {(1.0 * $i / ($argv))}]
+  set y [expr {int($x * $n)}]
+  puts [join [list $i $x $y $row($y)] "  \t"]
+}
hunk ./split-points.sh 1
+ghc --make tcl.hs repl.hs  && head -99 /tmp/nsst  | ./repl  split-points.pcl    10   2>&1 | tee /tmp/o
hunk ./tcl.hs 184
+      M.insert "split" (Builtin builtin_split) $
hunk ./tcl.hs 225
-builtin_gets [bufVarName] = do
+builtin_gets ["stdin", bufVarName] = do
hunk ./tcl.hs 245
+builtin_split :: [String] -> Action
+builtin_split [str] = good $ joinTclList $ splitOnWhite str
+builtin_split [str, (c:[])] = good $ joinTclList $ splitOnChar c str
+
hunk ./tcl.hs 293
+builtin_incr [name] = builtin_incr [name, "1"]
hunk ./tcl.hs 395
-  case x of
-    Left e -> do
-      return $ Left e
-    Right s -> do
+  x `ifOk` \s -> do
hunk ./tcl.hs 410
-      case a of
-        Left z -> return $ Left z
-        Right s -> substWord' (s:stringsDone) (Word frags)
+      a `ifOk` \s -> substWord' (s:stringsDone) (Word frags)
hunk ./tcl.hs 438
-          frags <- parseDoubleQuotedFragments
-                   <|> do
-                     f <- parseFragment
-                     return [f]           ----TODO:  more frags
+          frags <- parseDoubleQuotedFragments <|> many1 parseFragment
hunk ./tcl.hs 574
-splitOnchar c s = z
+splitOnChar :: Char -> String -> [String]
+splitOnChar c s = z