+++ /dev/null
-! Numbers game example
-
-IN: numbers-game
-USE: combinators
-USE: kernel
-USE: math
-USE: parser
-USE: random
-USE: stdio
-USE: stack
-
-: read-number ( -- n ) read parse-number ;
-
-: guess-banner
- "I'm thinking of a number between 0 and 100." print ;
-: guess-prompt "Enter your guess: " write ;
-: too-high "Too high" print ;
-: too-low "Too low" print ;
-: correct "Correct - you win!" print ;
-
-: inexact-guess ( actual guess -- )
- < [ too-high ] [ too-low ] ifte ;
-
-: judge-guess ( actual guess -- ? )
- 2dup = [
- 2drop correct f
- ] [
- inexact-guess t
- ] ifte ;
-
-: number-to-guess ( -- n ) 0 100 random-int ;
-
-: numbers-game-loop ( actual -- )
- dup guess-prompt read-number judge-guess [
- numbers-game-loop
- ] [
- drop
- ] ifte ;
-
-: numbers-game number-to-guess numbers-game-loop ;
+++ /dev/null
-! Contractor timesheet example
-
-IN: timesheet
-USE: combinators
-USE: errors
-USE: format
-USE: kernel
-USE: lists
-USE: math
-USE: parser
-USE: stack
-USE: stdio
-USE: strings
-USE: unparser
-USE: vectors
-
-! Adding a new entry to the time sheet.
-
-: measure-duration ( -- duration )
- millis
- read drop
- millis swap - 1000 /i 60 /i ;
-
-: add-entry-prompt ( -- duration description )
- "Start work on the task now. Press ENTER when done." print
- measure-duration
- "Please enter a description:" print
- read ;
-
-: add-entry ( timesheet -- )
- add-entry-prompt cons swap vector-push ;
-
-! Printing the timesheet.
-
-: hh ( duration -- str ) 60 /i ;
-: mm ( duration -- str ) 60 mod unparse 2 digits ;
-: hh:mm ( millis -- str ) <% dup hh % ":" % mm % %> ;
-
-: print-entry ( duration description -- )
- dup write
- 60 swap pad-string write
- hh:mm print ;
-
-: print-timesheet ( timesheet -- )
- "TIMESHEET:" print
- [ uncons print-entry ] vector-each ;
-
-! Displaying a menu
-
-: print-menu ( menu -- )
- terpri [ cdr car print ] each terpri
- "Enter a letter between ( ) to execute that action." print ;
-
-: menu-prompt ( menu -- )
- read swap assoc dup [
- cdr call
- ] [
- "Invalid input: " swap unparse cat2 throw
- ] ifte ;
-
-: menu ( menu -- )
- dup print-menu menu-prompt ;
-
-! Main menu
-
-: main-menu ( timesheet -- )
- [
- [ "e" "(E)xit" drop ]
- [ "a" "(A)dd entry" dup add-entry main-menu ]
- [ "p" "(P)rint timesheet" dup print-timesheet main-menu ]
- ] menu ;
-
-: timesheet-app ( -- )
- 10 <vector> main-menu ;
--- /dev/null
+! Numbers game example
+
+IN: numbers-game
+USE: combinators
+USE: kernel
+USE: math
+USE: parser
+USE: random
+USE: stdio
+USE: stack
+
+: read-number ( -- n ) read parse-number ;
+
+: guess-banner
+ "I'm thinking of a number between 0 and 100." print ;
+: guess-prompt "Enter your guess: " write ;
+: too-high "Too high" print ;
+: too-low "Too low" print ;
+: correct "Correct - you win!" print ;
+
+: inexact-guess ( actual guess -- )
+ < [ too-high ] [ too-low ] ifte ;
+
+: judge-guess ( actual guess -- ? )
+ 2dup = [
+ 2drop correct f
+ ] [
+ inexact-guess t
+ ] ifte ;
+
+: number-to-guess ( -- n ) 0 100 random-int ;
+
+: numbers-game-loop ( actual -- )
+ dup guess-prompt read-number judge-guess [
+ numbers-game-loop
+ ] [
+ drop
+ ] ifte ;
+
+: numbers-game number-to-guess numbers-game-loop ;
--- /dev/null
+! Contractor timesheet example
+
+IN: timesheet
+USE: combinators
+USE: errors
+USE: format
+USE: kernel
+USE: lists
+USE: math
+USE: parser
+USE: stack
+USE: stdio
+USE: strings
+USE: unparser
+USE: vectors
+
+! Adding a new entry to the time sheet.
+
+: measure-duration ( -- duration )
+ millis
+ read drop
+ millis swap - 1000 /i 60 /i ;
+
+: add-entry-prompt ( -- duration description )
+ "Start work on the task now. Press ENTER when done." print
+ measure-duration
+ "Please enter a description:" print
+ read ;
+
+: add-entry ( timesheet -- )
+ add-entry-prompt cons swap vector-push ;
+
+! Printing the timesheet.
+
+: hh ( duration -- str ) 60 /i ;
+: mm ( duration -- str ) 60 mod unparse 2 digits ;
+: hh:mm ( millis -- str ) <% dup hh % ":" % mm % %> ;
+
+: print-entry ( duration description -- )
+ dup write
+ 60 swap pad-string write
+ hh:mm print ;
+
+: print-timesheet ( timesheet -- )
+ "TIMESHEET:" print
+ [ uncons print-entry ] vector-each ;
+
+! Displaying a menu
+
+: print-menu ( menu -- )
+ terpri [ cdr car print ] each terpri
+ "Enter a letter between ( ) to execute that action." print ;
+
+: menu-prompt ( menu -- )
+ read swap assoc dup [
+ cdr call
+ ] [
+ "Invalid input: " swap unparse cat2 throw
+ ] ifte ;
+
+: menu ( menu -- )
+ dup print-menu menu-prompt ;
+
+! Main menu
+
+: main-menu ( timesheet -- )
+ [
+ [ "e" "(E)xit" drop ]
+ [ "a" "(A)dd entry" dup add-entry main-menu ]
+ [ "p" "(P)rint timesheet" dup print-timesheet main-menu ]
+ ] menu ;
+
+: timesheet-app ( -- )
+ 10 <vector> main-menu ;
public class FactorInterpreter implements FactorObject, Runnable
{
- public static final String VERSION = "0.68";
+ public static final String VERSION = "0.69";
public static final Cons DEFAULT_USE = new Cons("builtins",
new Cons("syntax",new Cons("scratchpad",null)));
plugin.factor.jedit.FactorPlugin.activate=startup
plugin.factor.jedit.FactorPlugin.name=Factor
-plugin.factor.jedit.FactorPlugin.version=0.68
+plugin.factor.jedit.FactorPlugin.version=0.69
plugin.factor.jedit.FactorPlugin.author=Slava Pestov
plugin.factor.jedit.FactorPlugin.docs=/doc/jedit/index.html
cpu "x86" = [
[
- "hsv" test
+ "hsv"
"x86-compiler/simple"
"x86-compiler/stack"
"x86-compiler/ifte"
#! first two in a pair.
over vector-length [
pick pick 2vector-nth cons
- ] vector-collect nip nip ;
+ ] vector-project nip nip ;
: vector-2map ( v1 v2 quot -- v )
#! Apply a quotation with stack effect ( obj obj -- obj ) to