diff --git a/.travis.yml b/.travis.yml index ed10217d85..1dd0e38ca2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ - language: cpp compiler: - clang @@ -45,4 +44,4 @@ before_install: ( cd udis86-1.7.2/ && ./autogen.sh && ./configure --enable-shared=yes && make && sudo make install ) && ( [[ "$TRAVIS_OS_NAME" != "osx" ]] && sudo ldconfig || true ) script: - - ./build.sh net-bootstrap < /dev/null + - DEBUG=1 ./build.sh net-bootstrap < /dev/null diff --git a/basis/cocoa/touchbar/touchbar.factor b/basis/cocoa/touchbar/touchbar.factor index 9ec4a811e2..1c9af98ab6 100644 --- a/basis/cocoa/touchbar/touchbar.factor +++ b/basis/cocoa/touchbar/touchbar.factor @@ -7,17 +7,17 @@ IN: cocoa.touchbar : make-touchbar ( seq self -- touchbar ) [ NSTouchBar send: alloc send: init dup ] dip send: setDelegate: { - [ swap send: setDefaultItemIdentifiers: ] - [ swap send: setCustomizationAllowedItemIdentifiers: ] + [ swap send: \setDefaultItemIdentifiers: ] + [ swap send: \setCustomizationAllowedItemIdentifiers: ] [ nip ] } 2cleave ; :: make-NSTouchBar-button ( self identifier label-string action-string -- button ) NSCustomTouchBarItem send: alloc - identifier send: initWithIdentifier: :> item + identifier send: \initWithIdentifier: :> item NSButton label-string self - action-string lookup-selector send: buttonWithTitle:target:action: :> button - item button send: setView: + action-string lookup-selector send: \buttonWithTitle:target:action: :> button + item button send: \setView: item ; diff --git a/basis/game/input/gtk/gtk.factor b/basis/game/input/gtk/gtk.factor index e2084a1515..607c7d6ffc 100644 --- a/basis/game/input/gtk/gtk.factor +++ b/basis/game/input/gtk/gtk.factor @@ -13,7 +13,9 @@ LIBRARY: gdk FUNCTION: Display* gdk_x11_display_get_xdisplay ( GdkDisplay* display ) : get-dpy ( -- dpy ) - gdk_display_get_default gdk_x11_display_get_xdisplay ; + gdk_display_get_default [ gdk_x11_display_get_xdisplay ] [ + "No default display." throw + ] if* ; M: gtk-game-input-backend (open-game-input) reset-mouse ; diff --git a/basis/help/lint/checks/tags.txt b/basis/help/lint/checks/tags.txt new file mode 100644 index 0000000000..ef1aab0d0e --- /dev/null +++ b/basis/help/lint/checks/tags.txt @@ -0,0 +1 @@ +tools diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index d8e43a731e..134b0610cc 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -355,6 +355,8 @@ M: word ($instance) dup name>> a/an write bl ($link) ; M: string ($instance) write ; +M: array ($instance) print-element ; + M: f ($instance) ($link) ; : $instance ( element -- ) first ($instance) ; diff --git a/basis/opengl/shaders/shaders-docs.factor b/basis/opengl/shaders/shaders-docs.factor index 87185a43b1..7051364386 100644 --- a/basis/opengl/shaders/shaders-docs.factor +++ b/basis/opengl/shaders/shaders-docs.factor @@ -1,7 +1,28 @@ -USING: help.markup help.syntax io kernel math quotations -opengl.gl multiline assocs strings ; +USING: help.markup help.syntax kernel opengl.gl quotations sequences +strings ; IN: opengl.shaders +HELP: (gl-program) +{ $values + { "shaders" sequence } + { "quot" quotation } +} { $description + "Creates a gl program and attaches the shaders to it. Then applies the quotation to the program and finally links it." + } +{ $errors "Throws a gl error if linking the program fails." } ; + +HELP: +{ $values { "source" "The GLSL source code to compile" } { "kind" "The kind of shader to compile, such as " { $snippet "GL_VERTEX_SHADER" } " or " { $snippet "GL_FRAGMENT_SHADER" } } { "shader" "a new " { $link gl-shader } } } +{ $description "Tries to compile the given GLSL source into a shader object. The returned object can be checked for validity by " { $link check-gl-shader } " or " { $link gl-shader-ok? } ". Errors and warnings generated by the GLSL compiler will be collected in the info log, available from " { $link gl-shader-info-log } ".\n\nWhen the shader object is no longer needed, it should be deleted using " { $link glDeleteShader } " or else be attached to a " { $link gl-program } " object deleted using " { $link delete-gl-program } "." } ; + +HELP: +{ $values { "source" "The GLSL source code to compile" } { "vertex-shader" "a new " { $link vertex-shader } } } +{ $description "Tries to compile the given GLSL source into a vertex shader object. Equivalent to " { $snippet "GL_VERTEX_SHADER " } "." } ; + +HELP: +{ $values { "source" "The GLSL source code to compile" } { "fragment-shader" "a new " { $link fragment-shader } } } +{ $description "Tries to compile the given GLSL source into a fragment shader object. Equivalent to " { $snippet "GL_FRAGMENT_SHADER " } "." } ; + HELP: gl-shader { $class-description { $snippet "gl-shader" } " is a predicate class comprising values returned by OpenGL to represent shader objects. The following words are provided for creating and manipulating these objects:" { $list @@ -9,7 +30,7 @@ HELP: gl-shader { { $link gl-shader-ok? } " - Check whether a shader object compiled successfully" } { { $link check-gl-shader } " - Throw an error unless a shader object compiled successfully" } { { $link gl-shader-info-log } " - Retrieve the info log of messages generated by the GLSL compiler" } - { { $link delete-gl-shader } " - Invalidate a shader object" } + { { $link glDeleteShader } " - Invalidate a shader object" } } "The derived predicate classes " { $link vertex-shader } " and " { $link fragment-shader } " are also defined for the two standard kinds of shader defined by the OpenGL specification." } ; @@ -27,18 +48,6 @@ HELP: fragment-shader } } ; -HELP: -{ $values { "source" "The GLSL source code to compile" } { "kind" "The kind of shader to compile, such as " { $snippet "GL_VERTEX_SHADER" } " or " { $snippet "GL_FRAGMENT_SHADER" } } { "shader" "a new " { $link gl-shader } } } -{ $description "Tries to compile the given GLSL source into a shader object. The returned object can be checked for validity by " { $link check-gl-shader } " or " { $link gl-shader-ok? } ". Errors and warnings generated by the GLSL compiler will be collected in the info log, available from " { $link gl-shader-info-log } ".\n\nWhen the shader object is no longer needed, it should be deleted using " { $link delete-gl-shader } " or else be attached to a " { $link gl-program } " object deleted using " { $link delete-gl-program } "." } ; - -HELP: -{ $values { "source" "The GLSL source code to compile" } { "vertex-shader" "a new " { $link vertex-shader } } } -{ $description "Tries to compile the given GLSL source into a vertex shader object. Equivalent to " { $snippet "GL_VERTEX_SHADER " } "." } ; - -HELP: -{ $values { "source" "The GLSL source code to compile" } { "fragment-shader" "a new " { $link fragment-shader } } } -{ $description "Tries to compile the given GLSL source into a fragment shader object. Equivalent to " { $snippet "GL_FRAGMENT_SHADER " } "." } ; - HELP: gl-shader-ok? { $values { "shader" "A " { $link gl-shader } " object" } { "?" boolean } } { $description "Returns a boolean value indicating whether the given shader object compiled successfully. Compilation errors and warnings are available in the shader's info log, which can be gotten using " { $link gl-shader-info-log } "." } ; @@ -47,10 +56,6 @@ HELP: check-gl-shader { $values { "shader" "A " { $link gl-shader } " object" } } { $description "Throws an error containing the " { $link gl-shader-info-log } " for the shader object if it failed to compile. Otherwise, the shader object is left on the stack." } ; -HELP: delete-gl-shader -{ $values { "shader" "A " { $link gl-shader } " object" } } -{ $description "Deletes the shader object, invalidating it and releasing any resources allocated for it by the OpenGL implementation." } ; - HELP: gl-shader-info-log { $values { "shader" "A " { $link gl-shader } " object" } { "log" string } } { $description "Retrieves the info log for " { $snippet "shader" } ", including any errors or warnings generated in compiling the shader object." } ; @@ -92,7 +97,7 @@ HELP: gl-program-info-log HELP: delete-gl-program { $values { "program" "A " { $link gl-program } " object" } } -{ $description "Deletes the program object, invalidating it and releasing any resources allocated for it by the OpenGL implementation. Any attached " { $link gl-shader } "s are also deleted.\n\nIf the shader objects should be preserved, they should each be detached using " { $link detach-gl-program-shader } ". The program object can then be destroyed alone using " { $link delete-gl-program-only } "." } ; +{ $description "Deletes the program object, invalidating it and releasing any resources allocated for it by the OpenGL implementation. Any attached " { $link gl-shader } "s are also deleted.\n\nIf the shader objects should be preserved, they should each be detached using " { $link glDetachShader } ". The program object can then be destroyed alone using " { $link glDeleteProgram } "." } ; HELP: with-gl-program { $values { "program" "A " { $link gl-program } " object" } { "quot" "A quotation with stack effect " { $snippet "( program -- )" } } } diff --git a/basis/opengl/shaders/shaders.factor b/basis/opengl/shaders/shaders.factor index 231011c521..0c52028a31 100644 --- a/basis/opengl/shaders/shaders.factor +++ b/basis/opengl/shaders/shaders.factor @@ -54,24 +54,21 @@ IN: opengl.shaders : check-gl-shader ( shader -- shader ) dup gl-shader-ok? [ dup gl-shader-info-log throw ] unless ; -: delete-gl-shader ( shader -- ) glDeleteShader ; inline - PREDICATE: gl-shader < integer (gl-shader?) ; PREDICATE: vertex-shader < gl-shader (vertex-shader?) ; PREDICATE: fragment-shader < gl-shader (fragment-shader?) ; ! Programs +: attach-shaders ( program shaders -- ) + [ glAttachShader ] with each ; + : (gl-program) ( shaders quot: ( gl-program -- ) -- program ) glCreateProgram [ - [ swap [ glAttachShader ] with each ] - [ swap call ] bi-curry bi* + rot dupd attach-shaders swap call ] [ glLinkProgram ] [ ] tri gl-error ; inline -: ( shaders frag-data-locations -- program ) - [ [ first2 swap glBindFragDataLocation ] with each ] curry (gl-program) ; - : ( shaders -- program ) [ drop ] (gl-program) ; @@ -111,23 +108,18 @@ PREDICATE: fragment-shader < gl-shader (fragment-shader?) ; over uint [ glGetAttachedShaders ] keep [ zero? ] reject ; -: delete-gl-program-only ( program -- ) - glDeleteProgram ; inline - -: detach-gl-program-shader ( program shader -- ) - glDetachShader ; inline - : delete-gl-program ( program -- ) dup gl-program-shaders [ - 2dup detach-gl-program-shader delete-gl-shader - ] each delete-gl-program-only ; + 2dup glDetachShader glDeleteShader + ] each glDeleteProgram ; : with-gl-program ( program quot -- ) over glUseProgram [ 0 glUseProgram ] [ ] cleanup ; inline PREDICATE: gl-program < integer (gl-program?) ; -: ( vertex-shader-source fragment-shader-source -- program ) +: ( vertex-shader-source fragment-shader-source + -- program ) [ check-gl-shader ] [ check-gl-shader ] bi* 2array check-gl-program ; diff --git a/basis/tools/deploy/config/editor/editor.factor b/basis/tools/deploy/config/editor/editor.factor index e10d20e8b3..f4ef9cc2df 100644 --- a/basis/tools/deploy/config/editor/editor.factor +++ b/basis/tools/deploy/config/editor/editor.factor @@ -10,12 +10,12 @@ IN: tools.deploy.config.editor : deploy-config ( vocab -- assoc ) dup default-config swap - dup deploy-config-path vocab-file-contents + dup deploy-config-path vocab-file-lines parse-fresh [ first assoc-union ] unless-empty ; : set-deploy-config ( assoc vocab -- ) [ [ unparse-use ] without-limits string-lines ] dip - dup deploy-config-path set-vocab-file-contents ; + dup deploy-config-path set-vocab-file-lines ; : set-deploy-flag ( value key vocab -- ) [ deploy-config [ set-at ] keep ] keep set-deploy-config ; diff --git a/basis/ui/backend/gtk/gtk.factor b/basis/ui/backend/gtk/gtk.factor index 5e6cdaf3d0..7d35cc02aa 100644 --- a/basis/ui/backend/gtk/gtk.factor +++ b/basis/ui/backend/gtk/gtk.factor @@ -504,16 +504,14 @@ M:: gtk-ui-backend system-alert ( caption text -- ) ] with-destructors ; M: gtk-ui-backend (with-ui) + f f gtk_init_check [ "Unable to initialize GTK" throw ] unless + f f gtk_gl_init + load-icon + init-clipboard + start-ui [ - f f gtk_init - f f gtk_gl_init - load-icon - init-clipboard - start-ui - [ - [ [ gtk_main ] with-timer ] with-event-loop - ] with-destructors - ] with-ui-running ; + [ [ gtk_main ] with-timer ] with-event-loop + ] with-destructors ; M: gtk-ui-backend stop-event-loop gtk_main_quit ; diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index ba62aa0405..c7bed84a4f 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -706,13 +706,11 @@ M: windows-ui-backend set-title ( string world -- ) M: windows-ui-backend (with-ui) [ - [ - init-clipboard - init-win32-ui - start-ui - event-loop - ] [ cleanup-win32-ui ] [ ] cleanup - ] with-ui-running ; + init-clipboard + init-win32-ui + start-ui + event-loop + ] [ cleanup-win32-ui ] [ ] cleanup ; M: windows-ui-backend beep ( -- ) 0 MessageBeep drop ; diff --git a/basis/ui/backend/x11/x11.factor b/basis/ui/backend/x11/x11.factor index 143db07a48..deeca9b49e 100644 --- a/basis/ui/backend/x11/x11.factor +++ b/basis/ui/backend/x11/x11.factor @@ -319,15 +319,13 @@ M: x11-handle flush-gl-context ( handle -- ) dpy get swap window>> glXSwapBuffers ; M: x11-ui-backend (with-ui) ( quot -- ) - [ - f [ - [ - init-clipboard - start-ui - event-loop - ] with-xim - ] with-x - ] with-ui-running ; + f [ + [ + init-clipboard + start-ui + event-loop + ] with-xim + ] with-x ; M: x11-ui-backend beep ( -- ) dpy get 100 XBell drop ; diff --git a/basis/ui/ui-docs.factor b/basis/ui/ui-docs.factor index 9fd9e77037..bb8f34c1d9 100644 --- a/basis/ui/ui-docs.factor +++ b/basis/ui/ui-docs.factor @@ -3,7 +3,6 @@ math.rectangles namespaces quotations sequences strings ui.backend ui.gadgets ui.gadgets.books ui.gadgets.grids ui.gadgets.packs ui.gadgets.private ui.gadgets.tracks ui.gadgets.worlds ui.private ui.text vocabs.loader ; - IN: ui HELP: close-window @@ -91,7 +90,10 @@ HELP: raise-window HELP: with-ui { $values { "quot" { $quotation ( -- ) } } } -{ $description "Calls the quotation, starting the UI if necessary. If starting the UI is necessary, this word does not return and the UI will start after the quotation returns." } +{ $description + "Calls the quotation, starting the UI if necessary. If starting the UI is necessary, this word does not return and the UI will start after the quotation returns." $nl + "While the combinator is running, " { $link ui-running? } " can be used by user code to determine whether it is running in a UI context or not." +} { $notes "This word should be used in the " { $link postpone: \MAIN: } " word of an application that uses the UI in order for the vocabulary to work when run from either the UI listener (" { $snippet "\"my-app\" run" } ") and the command line (" { $snippet "./factor -run=my-app" } ")." } { $examples "The " { $vocab-link "hello-ui" } " vocabulary implements a simple UI application which uses this word." } ; diff --git a/basis/ui/ui-tests.factor b/basis/ui/ui-tests.factor new file mode 100644 index 0000000000..f4885e8852 --- /dev/null +++ b/basis/ui/ui-tests.factor @@ -0,0 +1,2 @@ +USING: assocs continuations kernel threads tools.test ui ; +IN: ui.tests diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index 22b085cb6b..2d422ef426 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -134,10 +134,6 @@ M: world ungraft* SYMBOL: ui-running -: with-ui-running ( quot -- ) - t ui-running set-global - [ f ui-running set-global ] [ ] cleanup ; inline - PRIVATE> : find-windows ( quot: ( world -- ? ) -- seq ) @@ -225,7 +221,15 @@ M: object resize-window 2drop ; [ find-world [ dup pref-dim resize-window ] when* ] bi ; : with-ui ( quot: ( -- ) -- ) - ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ; + ui-running? [ call( -- ) ] [ + t ui-running set-global '[ + [ init-ui @ ] (with-ui) + ] [ + f ui-running set-global + ! Give running ui threads a chance to finish. + notify-ui-thread yield + ] [ ] cleanup + ] if ; HOOK: beep ui-backend ( -- ) diff --git a/basis/vocabs/cache/cache.factor b/basis/vocabs/cache/cache.factor index 3e13393058..e1ff37984b 100644 --- a/basis/vocabs/cache/cache.factor +++ b/basis/vocabs/cache/cache.factor @@ -9,7 +9,7 @@ IN: vocabs.cache vocab-name [ root-cache get delete-at ] [ - \ vocab-file-contents "memoize" word-prop swap + \ vocab-file-lines "memoize" word-prop swap '[ drop first vocab-name _ = ] assoc-reject! drop ] bi \ all-disk-vocabs-recursive reset-memoized diff --git a/basis/vocabs/metadata/metadata-docs.factor b/basis/vocabs/metadata/metadata-docs.factor index 0c9b90bfb0..3fe93916b6 100644 --- a/basis/vocabs/metadata/metadata-docs.factor +++ b/basis/vocabs/metadata/metadata-docs.factor @@ -32,18 +32,18 @@ ARTICLE: "vocabs.metadata" "Vocabulary metadata" } "Getting and setting arbitrary vocabulary metadata:" { $subsections - vocab-file-contents - set-vocab-file-contents + vocab-file-lines + set-vocab-file-lines } ; ABOUT: "vocabs.metadata" -HELP: vocab-file-contents -{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "seq" { $maybe "a sequence of lines" } } } -{ $description "Outputs the contents of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ; +HELP: vocab-file-lines +{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "lines" { $maybe { $sequence "lines" } } } } +{ $description "Outputs the lines of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ; -HELP: set-vocab-file-contents -{ $values { "seq" "a sequence of lines" } { "vocab" "a vocabulary specifier" } { "name" string } } +HELP: set-vocab-file-lines +{ $values { "lines" { $sequence "lines" } } { "vocab" "a vocabulary specifier" } { "name" string } } { $description "Stores a sequence of lines to the file named " { $snippet "name" } " from the vocabulary's directory." } ; HELP: vocab-summary diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index c7bc010aec..b20e055f83 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -10,7 +10,7 @@ IN: vocabs.metadata : check-vocab ( vocab -- vocab ) dup find-vocab-root [ no-vocab ] unless ; -MEMO: vocab-file-contents ( vocab name -- seq ) +MEMO: vocab-file-lines ( vocab name -- lines/f ) vocab-append-path dup [ dup exists? [ utf8 file-lines harvest @@ -19,23 +19,23 @@ MEMO: vocab-file-contents ( vocab name -- seq ) ] if ] when ; -: set-vocab-file-contents ( seq vocab name -- ) +: set-vocab-file-lines ( lines vocab name -- ) dupd vocab-append-path [ swap [ ?delete-file ] [ swap utf8 set-file-lines ] if-empty - \ vocab-file-contents reset-memoized + \ vocab-file-lines reset-memoized ] [ vocab-name no-vocab ] ?if ; : vocab-resources-path ( vocab -- string ) vocab-dir "resources.txt" append-path ; : vocab-resources ( vocab -- patterns ) - dup vocab-resources-path vocab-file-contents ; + dup vocab-resources-path vocab-file-lines ; : vocab-summary-path ( vocab -- string ) vocab-dir "summary.txt" append-path ; : vocab-summary ( vocab -- summary ) - dup dup vocab-summary-path vocab-file-contents + dup dup vocab-summary-path vocab-file-lines [ vocab-name " vocabulary" append ] [ @@ -56,13 +56,13 @@ M: vocab-link summary vocab-summary ; vocab-dir "tags.txt" append-path ; : vocab-tags ( vocab -- tags ) - dup vocab-tags-path vocab-file-contents ; + dup vocab-tags-path vocab-file-lines ; : vocab-authors-path ( vocab -- string ) vocab-dir "authors.txt" append-path ; : vocab-authors ( vocab -- authors ) - dup vocab-authors-path vocab-file-contents ; + dup vocab-authors-path vocab-file-lines ; : vocab-platforms-path ( vocab -- string ) vocab-dir "platforms.txt" append-path ; @@ -70,7 +70,7 @@ M: vocab-link summary vocab-summary ; ERROR: bad-platform name ; : vocab-platforms ( vocab -- platforms ) - dup vocab-platforms-path vocab-file-contents + dup vocab-platforms-path vocab-file-lines [ dup "system" lookup-word [ ] [ bad-platform ] ?if ] map ; : supported-platform? ( platforms -- ? ) diff --git a/basis/vocabs/metadata/resources/resources.factor b/basis/vocabs/metadata/resources/resources.factor index ca1d0e95c5..354b893acb 100644 --- a/basis/vocabs/metadata/resources/resources.factor +++ b/basis/vocabs/metadata/resources/resources.factor @@ -33,10 +33,12 @@ ERROR: resource-missing pattern ; '[ _ match-pattern ] gather ; : vocab-resource-files ( vocab -- filenames ) - [ vocab-resources ] [ vocab-dir-in-root ] bi - [ - match-patterns [ expand-resource ] map concat - ] with-directory-files ; + dup vocab-resources [ + swap vocab-dir-in-root + [ + match-patterns [ expand-resource ] map concat + ] with-directory-files + ] [ drop f ] if* ; : copy-vocab-resources ( dir vocab -- ) dup vocab-resource-files diff --git a/extra/calendar/holidays/holidays.factor b/extra/calendar/holidays/holidays.factor index 9502019105..236b2d5881 100644 --- a/extra/calendar/holidays/holidays.factor +++ b/extra/calendar/holidays/holidays.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs calendar fry kernel locals parser -sequences vocabs words memoize ; +sequences vocabs words ; IN: calendar.holidays SINGLETONS: all world commonwealth-of-nations ; @@ -15,7 +15,10 @@ SYNTAX: \HOLIDAY: parse-definition ( timestamp/n -- timestamp ) define-declared ; SYNTAX: \HOLIDAY-NAME: - let[ scan-word "holiday" word-prop :> holidays scan-word :> name scan-object :> value + let[ + scan-word "holiday" word-prop :> holidays + scan-word :> name + scan-object :> value value name holidays set-at ] ; >> @@ -24,16 +27,14 @@ GENERIC: holidays ( n singleton -- seq ) -M: all holidays - drop - all-words [ "holiday" word-prop key? ] with filter ; +M: all holidays drop (holidays) ; : holiday? ( timestamp/n singleton -- ? ) [ holidays ] [ drop ] 2bi '[ _ same-day? ] any? ; diff --git a/extra/fuel/eval/eval-tests.factor b/extra/fuel/eval/eval-tests.factor index 2ac8704f87..ea461b4e43 100644 --- a/extra/fuel/eval/eval-tests.factor +++ b/extra/fuel/eval/eval-tests.factor @@ -50,10 +50,10 @@ IN: fuel.eval.tests ] unit-test { - "(nil nil \"9\\n\")\n<~FUEL~>\n" + "(nil 9 \"\")\n<~FUEL~>\n" } [ [ - { "3 sq . " } "hi99" - { "math" "prettyprint" "kernel" } eval-in-context + { "3 sq" } "hi99" + { "math" "kernel" } eval-in-context ] with-string-writer ] unit-test diff --git a/extra/fuel/eval/eval.factor b/extra/fuel/eval/eval.factor index 73ac9f607e..1e0cd4111e 100644 --- a/extra/fuel/eval/eval.factor +++ b/extra/fuel/eval/eval.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Jose Antonio Ortega Ruiz. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays continuations debugger fuel.pprint io +USING: accessors arrays continuations debugger fry fuel.pprint io io.streams.string kernel listener namespaces parser.notes prettyprint.config sequences sets vocabs.parser ; IN: fuel.eval @@ -8,9 +8,6 @@ IN: fuel.eval SYMBOL: restarts-stack V{ } clone restarts-stack set-global -SYMBOL: eval-result -f eval-result set-global - SYMBOL: eval-res-flag t eval-res-flag set-global @@ -31,14 +28,14 @@ t eval-res-flag set-global "<~FUEL~>" write nl flush ; : begin-eval ( -- ) - f eval-result set-global push-status ; + push-status ; -: end-eval ( error/f output -- ) - eval-result get-global swap send-retort pop-status ; +: end-eval ( result error/f output -- ) + swapd send-retort pop-status ; -: eval ( lines -- error/f ) - [ parse-lines-interactive call( -- ) f ] curry - [ dup print-error ] recover ; +: eval ( lines -- result error/f ) + '[ _ parse-lines-interactive call( -- x ) f ] + [ dup print-error f swap ] recover ; : eval-usings ( usings -- ) [ [ use-vocab ] curry ignore-errors ] each ; diff --git a/extra/fuel/fuel-tests.factor b/extra/fuel/fuel-tests.factor index 40dab3dda5..6e636302ae 100644 --- a/extra/fuel/fuel-tests.factor +++ b/extra/fuel/fuel-tests.factor @@ -28,6 +28,6 @@ IN: fuel.tests [ make-uses-restart is-suggested-restart? ] with-variable ] unit-test -{ } [ +{ f } [ { "kernel" } [ "\\ dup drop" eval( -- ) ] fuel-use-suggested-vocabs ] unit-test diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index d99fd3529b..585c5f46ef 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -1,13 +1,12 @@ ! Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs compiler.units continuations fuel.eval +USING: accessors assocs compiler.units continuations fry fuel.eval fuel.help fuel.xref help.topics io.pathnames kernel namespaces parser -parser.notes sequences tools.scaffold vocabs vocabs.files +parser.notes sequences source-files tools.scaffold vocabs vocabs.files vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.parser words ; IN: fuel ! Evaluation - : fuel-eval-restartable ( -- ) t eval-res-flag set-global ; inline @@ -17,9 +16,6 @@ IN: fuel : fuel-eval-in-context ( lines in usings -- ) eval-in-context ; -: fuel-eval-set-result ( obj -- ) - clone eval-result set-global ; inline - : fuel-retort ( -- ) f f "" send-retort ; inline ! Loading files @@ -44,134 +40,147 @@ SYMBOL: :uses-suggestions restarts get [ is-suggested-restart? ] filter dup length 1 = [ first continue-restart ] [ drop ] if ; -: set-use-hook ( -- ) - [ manifest get auto-used>> clone :uses prefix fuel-eval-set-result ] - print-use-hook set ; +SYMBOL: auto-uses -: get-uses ( lines -- ) +: set-use-hook ( -- ) [ - parser-quiet? on - parse-fresh drop - ] curry with-compilation-unit ; inline + manifest get auto-used>> clone :uses prefix + clone auto-uses set-global + ] print-use-hook set ; PRIVATE> -: fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b ) -- ..b ) +: fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b ) + -- ..b result ) + f auto-uses set-global [ :uses-suggestions set ] dip - [ try-suggested-restarts rethrow ] recover ; inline + [ try-suggested-restarts rethrow ] recover + auto-uses get-global ; inline -: fuel-run-file ( path -- ) - [ set-use-hook run-file ] curry with-scope ; inline +: fuel-run-file ( path -- result ) + f auto-uses set-global + '[ set-use-hook _ run-file ] with-scope + auto-uses get-global ; inline : fuel-with-autouse ( ..a quot: ( ..a -- ..b ) -- ..b ) - [ set-use-hook call ] curry with-scope ; inline + '[ set-use-hook _ call ] with-scope ; inline -: fuel-get-uses ( lines -- ) - [ get-uses ] curry fuel-with-autouse ; +: fuel-get-uses ( name lines -- ) + '[ + [ + _ [ + parser-quiet? on + _ parse-fresh drop + ] with-source-file + ] with-compilation-unit + ] fuel-with-autouse ; ! Edit locations +: fuel-get-word-location ( word -- result ) + word-location ; -: fuel-get-word-location ( word -- ) - word-location fuel-eval-set-result ; +: fuel-get-vocab-location ( vocab -- result ) + vocab-location ; -: fuel-get-vocab-location ( vocab -- ) - vocab-location fuel-eval-set-result ; +: fuel-get-doc-location ( word -- result ) + doc-location ; -: fuel-get-doc-location ( word -- ) - doc-location fuel-eval-set-result ; +: fuel-get-article-location ( name -- result ) + article-location ; -: fuel-get-article-location ( name -- ) - article-location fuel-eval-set-result ; +: fuel-get-vocabs ( -- reuslt ) + all-disk-vocab-names ; -: fuel-get-vocabs ( -- ) - all-disk-vocab-names fuel-eval-set-result ; +: fuel-get-vocabs/prefix ( prefix -- result ) + get-vocabs/prefix ; -: fuel-get-vocabs/prefix ( prefix -- ) - get-vocabs/prefix fuel-eval-set-result ; - -: fuel-get-words ( prefix names -- ) - get-vocabs-words/prefix fuel-eval-set-result ; +: fuel-get-words ( prefix names -- result ) + get-vocabs-words/prefix ; ! Cross-references -: fuel-callers-xref ( word -- ) callers-xref fuel-eval-set-result ; +: fuel-callers-xref ( word -- result ) callers-xref ; -: fuel-callees-xref ( word -- ) callees-xref fuel-eval-set-result ; +: fuel-callees-xref ( word -- result ) callees-xref ; -: fuel-apropos-xref ( str -- ) apropos-xref fuel-eval-set-result ; +: fuel-apropos-xref ( str -- result ) apropos-xref ; -: fuel-vocab-xref ( vocab -- ) vocab-xref fuel-eval-set-result ; +: fuel-vocab-xref ( vocab -- result ) vocab-xref ; -: fuel-vocab-uses-xref ( vocab -- ) vocab-uses-xref fuel-eval-set-result ; +: fuel-vocab-uses-xref ( vocab -- result ) vocab-uses-xref ; -: fuel-vocab-usage-xref ( vocab -- ) vocab-usage-xref fuel-eval-set-result ; +: fuel-vocab-usage-xref ( vocab -- result ) vocab-usage-xref ; ! Help support -: fuel-get-article ( name -- ) fuel.help::get-article fuel-eval-set-result ; +: fuel-get-article ( name -- result ) + fuel.help:get-article ; -: fuel-get-article-title ( name -- ) - articles get at [ article-title ] [ f ] if* fuel-eval-set-result ; +: fuel-get-article-title ( name -- result ) + articles get at [ article-title ] [ f ] if* ; -: fuel-word-help ( name -- ) word-help fuel-eval-set-result ; +: fuel-word-help ( name -- result ) word-help ; -: fuel-word-def ( name -- ) word-def fuel-eval-set-result ; +: fuel-word-def ( name -- result ) word-def ; -: fuel-vocab-help ( name -- ) fuel.help::vocab-help fuel-eval-set-result ; +: fuel-vocab-help ( name -- result ) fuel.help:vocab-help ; -: fuel-word-synopsis ( word -- ) word-synopsis fuel-eval-set-result ; +: fuel-word-synopsis ( word -- synopsis ) + word-synopsis ; -: fuel-vocab-summary ( name -- ) - fuel.help::vocab-summary fuel-eval-set-result ; +: fuel-vocab-summary ( name -- summary ) + fuel.help:vocab-summary ; -: fuel-index ( quot -- ) call( -- seq ) format-index fuel-eval-set-result ; +: fuel-index ( quot -- result ) + call( -- seq ) format-index ; -: fuel-get-vocabs/tag ( tag -- ) - get-vocabs/tag fuel-eval-set-result ; +: fuel-get-vocabs/tag ( tag -- result ) + get-vocabs/tag ; -: fuel-get-vocabs/author ( author -- ) - get-vocabs/author fuel-eval-set-result ; +: fuel-get-vocabs/author ( author -- result ) + get-vocabs/author ; ! Scaffold support : scaffold-name ( devname -- ) [ developer-name set ] when* ; -: fuel-scaffold-vocab ( root name devname -- ) +: fuel-scaffold-vocab ( root name devname -- result ) [ scaffold-name dup [ scaffold-vocab ] dip ] with-scope - dup require vocab-source-path absolute-path fuel-eval-set-result ; + dup require vocab-source-path absolute-path ; -: fuel-scaffold-help ( name devname -- ) +: fuel-scaffold-help ( name devname -- result ) [ scaffold-name dup require dup scaffold-docs ] with-scope - vocab-docs-path absolute-path fuel-eval-set-result ; + vocab-docs-path absolute-path ; -: fuel-scaffold-tests ( name devname -- ) +: fuel-scaffold-tests ( name devname -- result ) [ scaffold-name dup require dup scaffold-tests ] with-scope - vocab-tests-file absolute-path fuel-eval-set-result ; + vocab-tests-file absolute-path ; -: fuel-scaffold-authors ( name devname -- ) +: fuel-scaffold-authors ( name devname -- result ) [ scaffold-name dup require dup scaffold-authors ] with-scope - [ vocab-authors-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ; + [ vocab-authors-path ] keep swap vocab-append-path absolute-path ; -: fuel-scaffold-tags ( name tags -- ) +: fuel-scaffold-tags ( name tags -- result ) [ scaffold-tags ] [ drop [ vocab-tags-path ] keep swap - vocab-append-path absolute-path fuel-eval-set-result + vocab-append-path absolute-path ] 2bi ; -: fuel-scaffold-summary ( name summary -- ) +: fuel-scaffold-summary ( name summary -- result ) [ scaffold-summary ] [ drop [ vocab-summary-path ] keep swap - vocab-append-path absolute-path fuel-eval-set-result + vocab-append-path absolute-path ] 2bi ; -: fuel-scaffold-platforms ( name platforms -- ) +: fuel-scaffold-platforms ( name platforms -- result ) [ scaffold-platforms ] [ drop [ vocab-platforms-path ] keep swap - vocab-append-path absolute-path fuel-eval-set-result + vocab-append-path absolute-path ] 2bi ; -: fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ; +: fuel-scaffold-get-root ( name -- result ) + find-vocab-root ; diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index 58edf77564..1ab8e0b0bd 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -1,10 +1,11 @@ ! Copyright (C) 2009 Jose Antonio Ortega Ruiz. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs combinators combinators.short-circuit -fry help help.crossref help.markup help.markup.private help.topics -help.vocabs io io.streams.string kernel make namespaces parser -prettyprint see sequences splitting summary vocabs vocabs.hierarchy -vocabs.metadata vocabs.parser words ; +USING: accessors arrays assocs combinators +combinators.short-circuit help help.crossref help.markup +help.markup.private help.topics help.vocabs io io.streams.string +kernel make namespaces parser prettyprint see sequences +splitting summary vocabs vocabs.hierarchy vocabs.metadata +vocabs.parser words ; IN: fuel.help SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ; @@ -35,7 +36,7 @@ SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ; > _ = ] all-words swap find nip ] } 1|| ; + { [ search ] [ words-named ?first ] } 1|| ; : definition-str ( word -- str ) [ see ] with-string-writer ; inline diff --git a/extra/gdbm/ffi/ffi.factor b/extra/gdbm/ffi/ffi.factor index 4d1117b55d..e6a1f9a2aa 100755 --- a/extra/gdbm/ffi/ffi.factor +++ b/extra/gdbm/ffi/ffi.factor @@ -42,6 +42,9 @@ FUNCTION: int gdbm_exists ( GDBM_FILE dbf, datum key ) FUNCTION: int gdbm_setopt ( GDBM_FILE dbf, int option, int* value, int size ) FUNCTION: int gdbm_fdesc ( GDBM_FILE dbf ) +! Removed in gdbm 1.14 C-GLOBAL: int gdbm_errno +! Added in gdbm 1.14 +FUNCTION: int *gdbm_errno_location ( ) FUNCTION: c-string gdbm_strerror ( int errno ) diff --git a/extra/gdbm/gdbm.factor b/extra/gdbm/gdbm.factor index b7573072a5..f92d243a56 100644 --- a/extra/gdbm/gdbm.factor +++ b/extra/gdbm/gdbm.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2010 Dmitry Shubin. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.data alien.destructors -alien.enums alien.syntax classes.struct combinators destructors -fry gdbm.ffi io.backend kernel libc locals math namespaces +alien.enums alien.syntax classes.struct combinators continuations +destructors fry gdbm.ffi io.backend kernel libc locals math namespaces sequences serialize strings ; IN: gdbm @@ -41,10 +41,12 @@ ENUM: gdbm-error gdbm-option-already-set gdbm-illegal-option ; - enum throw ; +: gdbm-errno ( -- n ) + [ gdbm_errno ] [ drop gdbm_errno_location int deref ] recover ; + +: gdbm-throw ( -- * ) gdbm-errno gdbm-error number>enum throw ; : check-error ( ret -- ) 0 = [ gdbm-throw ] unless ; diff --git a/extra/git/git-tests.factor b/extra/git/git-tests.factor index 5022df4ba4..e36464fd30 100644 --- a/extra/git/git-tests.factor +++ b/extra/git/git-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2015 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: fry git io io.directories io.encodings.utf8 io.files.temp -io.files.unique io.launcher kernel sequences tools.test ; +USING: accessors fry git io io.directories io.encodings.utf8 +io.launcher io.streams.string kernel sequences tools.test ; IN: git.tests : run-process-stdout ( process -- string ) @@ -21,6 +21,12 @@ IN: git.tests @ ] with-empty-test-git-repo ; inline +{ "hello" } [ + commit new "author" "hello\r\n" + [ parse-commit-field ] with-string-reader + author>> +] unit-test + { "refs/heads/master" } [ [ git-head-ref ] with-empty-test-git-repo ] unit-test diff --git a/extra/git/git.factor b/extra/git/git.factor index fff6a8a031..290d023776 100644 --- a/extra/git/git.factor +++ b/extra/git/git.factor @@ -148,11 +148,6 @@ CONSTRUCTOR: tree ( -- obj ) ; ERROR: unknown-commit-line line name ; -ERROR: string-expected got expected ; - -: expect-string ( string expected -- ) - 2dup = [ 2drop ] [ string-expected ] if ; - ERROR: eof-too-early ; ERROR: unknown-field field ; @@ -175,13 +170,11 @@ ERROR: unexpected-text text ; } case ; : parse-commit ( bytes -- commit ) - " " split1 [ "commit" expect-string ] [ string>number read ] bi* + " " split1 [ "commit" assert= ] [ string>number read ] bi* utf8 [ commit new parse-commit-lines ] with-byte-reader ; - - : parse-tree-field ( obj parameter -- obj ) [ "\r\n" read-until* ] dip { { "tree" [ >>tree ] } @@ -504,8 +497,6 @@ ERROR: repeated-parent-hash hash ; H{ } clone parents [ git-head-object [ parents>> dup string? [ random ] unless [ - ! [ parents get 2dup key? [ repeated-parent-hash ] when dupd set-at ] keep - ! dup "parent: " prepend print flush yield dup git-unpacked-object-exists? [ git-read-object ] [ git-object-from-pack ] if ] [ f ] if* diff --git a/extra/google/gmail/gmail-docs.factor b/extra/google/gmail/gmail-docs.factor new file mode 100644 index 0000000000..459d1f5d53 --- /dev/null +++ b/extra/google/gmail/gmail-docs.factor @@ -0,0 +1,23 @@ +! Copyright (C) 2018 Björn Lindqvist. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax ; +IN: google.gmail + +ARTICLE: "google.gmail" "GMail Client" +"This vocab implements an api to GMail based on " { $vocab-link "oauth2" } "." +$nl +"To use the vocab, it first needs to be supplied the 'Client ID' and 'Client secret settings' using the " { $link configure-oauth2 } " vord:" +{ $unchecked-example + "\"client-id\" \"client-secret\" configure-oauth2" +} +"The settings can be found on Google's developer console at " { $url "https://console.developers.google.com" } ". Then the authenticated users labels can be listed using:" +{ $unchecked-example + "list-labels" +} +"Or to list the first message in the users inbox:" +{ $unchecked-example + "\"INBOX\" list-messages-by-label \"messages\" of" + "first \"id\" of { } get-messages" +} ; + +ABOUT: "google.gmail" diff --git a/extra/google/gmail/gmail.factor b/extra/google/gmail/gmail.factor index a5ff85235e..29b5d1fa5c 100644 --- a/extra/google/gmail/gmail.factor +++ b/extra/google/gmail/gmail.factor @@ -11,20 +11,20 @@ CONSTANT: token-uri "https://www.googleapis.com/oauth2/v4/token" CONSTANT: redirect-uri "urn:ietf:wg:oauth:2.0:oob" CONSTANT: gmail-scope-ro "https://www.googleapis.com/auth/gmail.readonly" -SYMBOL: access-token +SYMBOLS: access-token google-oauth2 ; : configure-oauth2 ( client-id client-secret -- ) [ auth-uri token-uri redirect-uri ] 2dip gmail-scope-ro { } - oauth2 boa oauth2 set ; + oauth2 boa google-oauth2 set ; : ensure-token ( -- ) access-token [ [ dup access-expired? [ - oauth2 get over refresh-flow update-tokens + google-oauth2 get over refresh-flow update-tokens ] when ] [ - oauth2 get console-flow + google-oauth2 get console-flow ] if* ] change ; diff --git a/extra/gpu/gpu-docs.factor b/extra/gpu/gpu-docs.factor index c92e878119..6933ba1979 100644 --- a/extra/gpu/gpu-docs.factor +++ b/extra/gpu/gpu-docs.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax ui.gadgets.worlds ; +USING: gpu.private help.markup help.syntax ui.gadgets.worlds ; IN: gpu HELP: finish-gpu @@ -15,6 +15,9 @@ HELP: flush-gpu HELP: gpu-object { $class-description "Parent class of all GPU resources." } ; +HELP: has-vertex-array-objects? +{ $var-description "Whether the opengl version supports Vertex Array Objects or not." } ; + HELP: init-gpu { $description "Initializes the current graphics context for use with the " { $snippet "gpu" } " library. This should be the first thing called in a world's " { $link begin-world } " method." } ; diff --git a/extra/gpu/shaders/shaders-docs.factor b/extra/gpu/shaders/shaders-docs.factor index be75417b7b..e9fc744998 100644 --- a/extra/gpu/shaders/shaders-docs.factor +++ b/extra/gpu/shaders/shaders-docs.factor @@ -1,9 +1,17 @@ ! Copyright (C) 2009 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: classes classes.struct gpu.buffers help.markup help.syntax -images kernel math multiline quotations sequences strings words ; +USING: classes classes.struct gpu.buffers gpu.shaders.private +help.markup help.syntax images math sequences strings words ; IN: gpu.shaders +HELP: +{ $values + { "vertex-formats" "a list of " { $link buffer-ptr } "/" { $link vertex-format } " pairs" } + { "program-instance" program-instance } + { "vertex-array" vertex-array } +} +{ $description "Creates a new " { $link vertex-array } " to feed data to " { $snippet "program-instance" } " from the set of " { $link buffer } "s specified in " { $snippet "vertex-formats" } ". The first element of each pair in " { $snippet "vertex-formats" } " can be either a " { $link buffer-ptr } " or a " { $link buffer } "; in the latter case, vertex data in the associated format is read from the beginning of the buffer." } ; + HELP: { $values { "program" program } @@ -18,13 +26,13 @@ HELP: } { $description "Compiles an instance of " { $snippet "shader" } " for the current graphics context. If an instance already exists for " { $snippet "shader" } " in the current context, it is reused." } ; -HELP: +HELP: { $values - { "vertex-formats" "a list of " { $link buffer-ptr } "/" { $link vertex-format } " pairs" } - { "program-instance" program-instance } - { "vertex-array" vertex-array } + { "vertex-buffer" "a vertex buffer" } + { "program-instance" program-instance } + { "format" vertex-format } } -{ $description "Creates a new " { $link vertex-array } " to feed data to " { $snippet "program-instance" } " from the set of " { $link buffer } "s specified in " { $snippet "vertex-formats" } ". The first element of each pair in " { $snippet "vertex-formats" } " can be either a " { $link buffer-ptr } " or a " { $link buffer } "; in the latter case, vertex data in the associated format is read from the beginning of the buffer." } ; +{ $description "Creates a new vertex array object." } ; HELP: \feedback-format: { $syntax "feedback-format: vertex-format" } @@ -32,7 +40,7 @@ HELP: \feedback-format: HELP: \GLSL-PROGRAM: { $syntax "GLSL-PROGRAM: program-name shader shader ... [vertex-format vertex-format ...] [feedback-format: vertex-format] ;" } -{ $description "Defines a new " { $link program } " named " { $snippet "program-name" } ". When the program is instantiated with " { $link } ", it will link together instances of all of the specified " { $link shader } "s to create the program instance. If any " { $link vertex-format } "s are specified, their attributes will be pre-assigned attribute indexes at link time, to ensure that their indexes remain constant if the program is refreshed with " { $link refresh-program } ". A transform feedback vertex format may optionally be specified with " { $link postpone: \feedback-format: } "; if the program is used to collect transform feedback, the given vertex format will be used for the output." } +{ $description "Defines a new shader " { $link program } " named " { $snippet "program-name" } ". When the program is instantiated with " { $link } ", it will link together instances of all of the specified " { $link shader } "s to create the program instance. If any " { $link vertex-format } "s are specified, their attributes will be pre-assigned attribute indexes at link time, to ensure that their indexes remain constant if the program is refreshed with " { $link refresh-program } ". A transform feedback vertex format may optionally be specified with " { $link POSTPONE: feedback-format: } "; if the program is used to collect transform feedback, the given vertex format will be used for the output." } { $notes "Transform feedback requires OpenGL 3.0 or one of the " { $snippet "GL_EXT_transform_feedback" } " or " { $snippet "GL_ARB_transform_feedback" } " extensions." } ; HELP: \GLSL-SHADER-FILE: diff --git a/extra/gpu/shaders/shaders-tests.factor b/extra/gpu/shaders/shaders-tests.factor index b4b802d368..e97144126c 100644 --- a/extra/gpu/shaders/shaders-tests.factor +++ b/extra/gpu/shaders/shaders-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Joe Groff. ! See http://factorcode.org/license.txt for BSD license. -USING: multiline gpu.shaders gpu.shaders.private tools.test ; +USING: gpu.shaders gpu.shaders.private io.pathnames tools.test ; IN: gpu.shaders.tests { "ERROR: foo.factor:20: Bad command or filename @@ -10,3 +10,9 @@ NOT:A:LOG:LINE" } "ERROR: 0:1: Bad command or filename INFO: 0:11: The operation completed successfully NOT:A:LOG:LINE" replace-log-line-numbers ] unit-test + +SYMBOL: a-test-symbol + +{ "shaders" } [ + a-test-symbol word-directory file-name +] unit-test diff --git a/extra/gpu/shaders/shaders.factor b/extra/gpu/shaders/shaders.factor index 3592d5523e..de09c0c7ee 100755 --- a/extra/gpu/shaders/shaders.factor +++ b/extra/gpu/shaders/shaders.factor @@ -456,7 +456,7 @@ TUPLE: compile-shader-error shader log ; TUPLE: link-program-error program log ; : throw-compile-shader-error ( shader instance -- * ) - [ dup ] dip [ gl-shader-info-log ] [ delete-gl-shader ] bi + [ dup ] dip [ gl-shader-info-log ] [ glDeleteShader ] bi replace-log-line-numbers compile-shader-error boa throw ; : throw-link-program-error ( program instance -- * ) @@ -494,11 +494,14 @@ DEFER: : link-program ( program -- program-instance ) dup shaders>> [ ] map (link-program) ; +: word-directory ( word -- directory ) + where first parent-directory ; + : in-word's-path ( word kind filename -- word kind filename' ) - [ over ] dip [ where first parent-directory ] dip append-path ; + pick word-directory prepend-path ; : become-shader-instance ( shader-instance new-shader-instance -- ) - handle>> [ swap delete-gl-shader ] curry change-handle drop ; + handle>> [ swap glDeleteShader ] curry change-handle drop ; : refresh-shader-source ( shader -- ) dup filename>> @@ -506,7 +509,7 @@ DEFER: [ drop ] if* ; : become-program-instance ( program-instance new-program-instance -- ) - handle>> [ swap delete-gl-program-only ] curry change-handle drop ; + handle>> [ swap glDeleteProgram ] curry change-handle drop ; : reset-memos ( -- ) \ uniform-index reset-memoized @@ -622,11 +625,11 @@ SYNTAX: \GLSL-PROGRAM: define-constant ; M: shader-instance dispose - [ dup valid-handle? [ delete-gl-shader ] [ drop ] if f ] change-handle + [ dup valid-handle? [ glDeleteShader ] [ drop ] if f ] change-handle [ world>> ] [ shader>> instances>> ] [ ] tri ?delete-at ; M: program-instance dispose - [ dup valid-handle? [ delete-gl-program-only ] [ drop ] if f ] change-handle + [ dup valid-handle? [ glDeleteProgram ] [ drop ] if f ] change-handle [ world>> ] [ program>> instances>> ] [ ] tri ?delete-at reset-memos ; diff --git a/extra/gpu/util/util-docs.factor b/extra/gpu/util/util-docs.factor new file mode 100644 index 0000000000..dc8521a16c --- /dev/null +++ b/extra/gpu/util/util-docs.factor @@ -0,0 +1,5 @@ +USING: help.markup help.syntax ; +IN: gpu.util + +HELP: window-vertex-format +{ $class-description "A vertex format for screen coordinates." } ; diff --git a/extra/gpu/util/wasd/wasd-docs.factor b/extra/gpu/util/wasd/wasd-docs.factor new file mode 100644 index 0000000000..0627e117d3 --- /dev/null +++ b/extra/gpu/util/wasd/wasd-docs.factor @@ -0,0 +1,11 @@ +USING: help.markup help.syntax math ; +IN: gpu.util.wasd + +HELP: wasd-world +{ $class-description "A wasd-world is a 3d world in which the camera can move using the keybindings 'w', 'a', 's' and 'd' and the view can rotate using the camera." } ; + +HELP: wasd-near-plane +{ $values + { "world" wasd-world } + { "near-plane" float } +} { $description "Near plane of the 3d world." } ; diff --git a/extra/gtk-samples/opengl/opengl.factor b/extra/gtk-samples/opengl/opengl.factor index 6e2a090fec..66653a05ea 100644 --- a/extra/gtk-samples/opengl/opengl.factor +++ b/extra/gtk-samples/opengl/opengl.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 Anton Gorenko. ! See http://factorcode.org/license.txt for BSD license. USING: alien.strings gdk.gl.ffi gobject.ffi gtk.ffi gtk.gl.ffi -io.encodings.utf8 kernel locals opengl.gl ; +io.encodings.utf8 kernel locals opengl.demo-support opengl.gl ; IN: gtk-samples.opengl ! This sample is based on @@ -25,14 +25,14 @@ IN: gtk-samples.opengl [ GL_COLOR_BUFFER_BIT glClear - GL_TRIANGLES glBegin - 1.0 0.0 0.0 glColor3f - 0 1 glVertex2i - 0.0 1.0 0.0 glColor3f - -1 -1 glVertex2i - 0.0 0.0 1.0 glColor3f - 1 -1 glVertex2i - glEnd + GL_TRIANGLES [ + 1.0 0.0 0.0 glColor3f + 0 1 glVertex2i + 0.0 1.0 0.0 glColor3f + -1 -1 glVertex2i + 0.0 0.0 1.0 glColor3f + 1 -1 glVertex2i + ] do-state gl-drawable gdk_gl_drawable_is_double_buffered 1 = [ gl-drawable gdk_gl_drawable_swap_buffers ] diff --git a/extra/help/lint/coverage/authors.txt b/extra/help/lint/coverage/authors.txt new file mode 100644 index 0000000000..9d4a8e15ee --- /dev/null +++ b/extra/help/lint/coverage/authors.txt @@ -0,0 +1 @@ +Cat Stevens diff --git a/extra/help/lint/coverage/coverage-docs.factor b/extra/help/lint/coverage/coverage-docs.factor new file mode 100644 index 0000000000..76ccad0a10 --- /dev/null +++ b/extra/help/lint/coverage/coverage-docs.factor @@ -0,0 +1,183 @@ +USING: help help.lint.coverage help.lint.coverage.private +help.markup help.syntax io kernel sequences strings vocabs words ; +IN: help.lint.coverage + + + +ABOUT: "help.lint.coverage" + +ARTICLE: "help.lint.coverage" "Help coverage linting" +"The " { $vocab-link "help.lint.coverage" } " vocabulary implements a very picky documentation completeness checker." +$nl +"The documentation coverage linter requires most words to have " { $link postpone: \HELP: } " declarations defining some of the " +{ $links $values $description $error-description $class-description $examples } " sections (see " { $links "element-types" } ")." +$nl +"This vocabulary is intended to be used alongside and after " { $vocab-link "help.lint" } ", not as a replacement for it." +$nl +"These words are provided to aid in writing more complete documentation:" +{ $related-subsections + word-help-coverage. + vocab-help-coverage. + prefix-help-coverage. +} + +"Coverage report objects:" +{ $related-subsections + word-help-coverage + help-coverage. +} + +"Raw report generation:" +{ $related-subsections + + + +} ; + +{ word-help-coverage word-help-coverage. } +related-words + +HELP: word-help-coverage +{ $class-description "A documentation coverage report for a single word." } ; + +HELP: help-coverage. +{ $values { "coverage" word-help-coverage } } +{ $contract "Displays a coverage object." } +{ $examples + { $example + "USING: help.lint.coverage ;" + "\\ help-coverage." + "[help.lint.coverage] : full help coverage" + } +} ; + +HELP: word-help-coverage. +{ $values { "word-spec" { $or word string } } } +{ $description "Prettyprints a help coverage report of " { $snippet "word-spec" } " to " { $link output-stream } "." } +{ $examples + { $example + "USING: sequences help.lint.coverage ;" + "\\ map word-help-coverage." + "[sequences] map: needs help section: $examples" + } +} ; + +HELP: vocab-help-coverage. +{ $values { "vocab-spec" { $or vocab string } } } +{ $description "Prettyprints a help coverage report of " { $snippet "vocab-spec" } " to " { $link output-stream } "." } +{ $examples + { $example + "USING: help.lint.coverage ;" + "\"english\" vocab-help-coverage." +"[english] a10n: needs help sections: $description $examples +[english] count-of-things: needs help sections: $description $examples +[english] pluralize: needs help sections: $description $examples +[english] singularize: needs help sections: $description $examples + +0.0% of words have complete documentation" + } +} ; + +HELP: prefix-help-coverage. +{ $values { "prefix-spec" { $or vocab string } } { "private?" boolean } } +{ $description "Prettyprints a help coverage report of " { $snippet "prefix-spec" } " to " { $link output-stream } "." } +{ $examples + { $example + "USING: help.lint.coverage ;" + "\"english\" t prefix-help-coverage." +"[english] a10n: needs help sections: $description $examples +[english] count-of-things: needs help sections: $description $examples +[english] pluralize: needs help sections: $description $examples +[english] singularize: needs help sections: $description $examples +[english.private] match-case: needs help sections: $description $examples +[english.private] plural-to-singular: needs help sections: $description $examples +[english.private] singular-to-plural: needs help sections: $description $examples + +0.0% of words have complete documentation" + } +} ; + +HELP: +{ $values { "prefix" string } { "private?" boolean } { "coverage" sequence } } +{ $description "Runs the help coverage checker on every child vocabulary of the given " { $snippet "prefix" } ", including the base vocabulary. If " { $snippet "private?" } " is " { $snippet "f" } ", the prefix's child " { $snippet ".private" } " vocabularies are not checked. If " { $snippet "private?" } " is " { $snippet "t" } ", " { $emphasis "all" } " child vocabularies are checked." } +{ $examples + { $example + "USING: help.lint.coverage prettyprint ;" + "\"english\" t ." +"{ + T{ word-help-coverage + { word-name a10n } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name count-of-things } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name pluralize } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name singularize } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name match-case } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name plural-to-singular } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name singular-to-plural } + { omitted-sections { $description $examples } } + } +}" + } +} ; + +HELP: +{ $values { "word" { $or string word } } { "coverage" word-help-coverage } } +{ $contract "Looks up a word in the current scope and generates a documentation coverage report for it."} +{ $examples + { $example + "USING: help.lint.coverage prettyprint ;" + "\\ ." +"T{ word-help-coverage + { word-name } + { 100%-coverage? t } +}" + } +} ; + +HELP: +{ $values { "vocab-spec" { $or vocab string } } { "coverage" sequence } } +{ $description "Runs the help coverage checker on the vocabulary in the given " { $snippet "vocab-spec" } "." } +{ $examples + { $example + "USING: help.lint.coverage prettyprint ;" + "\"english\" ." +"{ + T{ word-help-coverage + { word-name a10n } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name count-of-things } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name pluralize } + { omitted-sections { $description $examples } } + } + T{ word-help-coverage + { word-name singularize } + { omitted-sections { $description $examples } } + } +}" + } +} ; diff --git a/extra/help/lint/coverage/coverage-tests.factor b/extra/help/lint/coverage/coverage-tests.factor new file mode 100644 index 0000000000..1839d6051e --- /dev/null +++ b/extra/help/lint/coverage/coverage-tests.factor @@ -0,0 +1,68 @@ +USING: accessors help.lint.coverage help.lint.coverage.private +help.markup help.syntax kernel literals math math.matrices +sequences sorting tools.test vocabs ; +IN: help.lint.coverage.tests + + + +{ t } [ \ empty empty-examples? ] unit-test +{ f } [ \ nonexistent empty-examples? ] unit-test +{ f } [ \ defined empty-examples? ] unit-test +{ f } [ \ keep empty-examples? ] unit-test + +{ { $description $values } } [ \ empty missing-sections natural-sort ] unit-test +{ { $description $values } } [ \ defined missing-sections natural-sort ] unit-test +{ { } } [ \ keep missing-sections ] unit-test + +{ { "a.b" "a.b.c" } } [ { "a.b" "a.b.private" "a.b.c.private" "a.b.c" } filter-private ] unit-test + +{ "sections" } [ 0 "section" ?pluralize ] unit-test +{ "section" } [ 1 "section" ?pluralize ] unit-test +{ "sections" } [ 10 "section" ?pluralize ] unit-test + +{ { $examples } } [ \ empty word-defines-sections ] unit-test +{ { $examples } } [ \ defined word-defines-sections ] unit-test +{ { } } [ \ nonexistent word-defines-sections ] unit-test +{ { $values $description $examples } } [ \ keep word-defines-sections ] unit-test +{ { $values $contract $examples } } [ \ word-defines-sections ] unit-test + +{ eye } [ "eye" find-word ] unit-test + +{ + V{ "[" { $[ "math" dup lookup-vocab ] } "] " { "zero?" zero? } ": " } +} [ + V{ } clone \ zero? (assemble-word-metadata) +] unit-test +{ + V{ "empty " { "$examples" $examples } "; " } +} [ + V{ } clone word-help-coverage new t >>empty-examples? (assemble-empty-examples) +] unit-test + +{ + V{ "needs help " "sections: " { { "$description" $description } { "$examples" $examples } } } +} [ + V{ } clone word-help-coverage new { $description $examples } >>omitted-sections (assemble-omitted-sections) +] unit-test +{ + V{ "needs help " "section: " { { "$description" $description } } } +} [ + V{ } clone word-help-coverage new { $description } >>omitted-sections (assemble-omitted-sections) +] unit-test +{ + V{ "full help coverage" } +} [ + V{ } clone word-help-coverage new t >>100%-coverage? (assemble-full-coverage) +] unit-test + +! make sure this doesn't throw an error (would signify an issue with ignored-words) +! the contents of all-words is not important +{ } [ all-words [ ] map drop ] unit-test diff --git a/extra/help/lint/coverage/coverage.factor b/extra/help/lint/coverage/coverage.factor new file mode 100644 index 0000000000..7c3b225b92 --- /dev/null +++ b/extra/help/lint/coverage/coverage.factor @@ -0,0 +1,155 @@ +USING: accessors arrays assocs classes classes.error combinators +continuations english formatting fry generic help +help.lint.checks help.markup io io.streams.string io.styles +kernel math namespaces parser sequences sequences.deep sets +sorting splitting strings summary vocabs vocabs.parser words ; +FROM: namespaces => set ; +IN: help.lint.coverage + +TUPLE: word-help-coverage + { word-name word initial: postpone: f } + { omitted-sections sequence initial: { } } + { empty-examples? boolean initial: f } + { 100%-coverage? boolean initial: f } ; + +> dup lookup-vocab 2array "] " + 3array over push-all + ] [ + [ name>> ] keep 2array ": " + 2array over push-all + ] bi ; inline + +: (assemble-empty-examples) ( vec coverage -- vec ) + empty-examples?>> [ "empty " \ $examples [ name>> ] keep 2array "; " + 3array over push-all + ] when ; + +: (assemble-omitted-sections) ( vec coverage -- vec ) + omitted-sections>> [ + length "section" ?pluralize ": " append + ] [ + [ [ name>> ] keep 2array ] map + ] bi + [ "needs help " ] 2dip + 3array over push-all ; + +: (assemble-full-coverage) ( vec coverage -- vec ) + drop "full help coverage" over push ; + +: (present-coverage) ( coverage-report -- ) + [ V{ } clone ] dip + [ word-name>> (assemble-word-metadata) ] keep + dup 100%-coverage?>> + [ (assemble-full-coverage) ] [ + [ (assemble-empty-examples) ] + [ (assemble-omitted-sections) ] bi + ] if "\n" over push write-object-seq ; + +M: word-help-coverage summary + [ (present-coverage) ] with-string-writer ; inline + +: sorted-loaded-child-vocabs ( prefix -- assoc ) + loaded-child-vocab-names natural-sort ; inline + +: filter-private ( seq -- no-private ) + [ ".private" ?tail nip not ] filter ; inline + +: ?pluralize ( n singular -- singular/plural ) + count-of-things " " split1 nip ; + +: should-define ( word -- spec ) + { + { [ dup predicate? ] [ drop { } ] } ! predicate?s have generated docs + { [ dup error-class? ] [ drop { $values $description $error-description } ] } + { [ dup class? ] [ drop { $class-description } ] } + { [ dup generic? ] [ drop { $values $contract $examples } ] } + { [ dup word? ] [ drop { $values $description $examples } ] } + [ drop no-cond ] + } cond ; + +: word-defines-sections ( word -- seq ) + word-help [ ignored-words member? not ] filter [ ?first ] map ; + +! only words that need examples, need to have them nonempty +! not defining examples is not the same as an empty { $examples } +: empty-examples? ( word -- ? ) + word-help \ $examples swap elements [ f ] [ first rest empty? ] if-empty ; + +: missing-sections ( word -- missing ) + [ should-define ] [ word-defines-sections ] bi diff ; + +: find-word ( name -- word/f ) + dup words-named dup length { + { 0 [ 2drop f ] } + { 1 [ first nip ] } + [ drop throw-restarts ] + } case ; + +PRIVATE> + +GENERIC: ( word -- coverage ) +M: word + dup [ missing-sections ] [ empty-examples? ] bi + 2dup 2array { { } f } = + word-help-coverage boa ; inline + +M: string + find-word ; inline + +: ( vocab-spec -- coverage ) + [ auto-use? off vocab-words natural-sort [ ] map ] with-scope ; + +: ( prefix private? -- coverage ) + [ + auto-use? off group-articles vocab-articles set + [ sorted-loaded-child-vocabs ] dip not + [ filter-private ] when + [ ] map flatten + ] with-scope ; + +GENERIC: help-coverage. ( coverage -- ) +M: sequence help-coverage. + [ + [ help-coverage. ] each + ] [ + [ [ 100%-coverage?>> ] count ] [ length ] bi /f + 100 * + "\n%3.1f%% of words have complete documentation\n" + printf + ] bi ; recursive + +M: word-help-coverage help-coverage. + (present-coverage) ; + +: word-help-coverage. ( word-spec -- ) help-coverage. ; +: vocab-help-coverage. ( vocab-spec -- ) help-coverage. ; +: prefix-help-coverage. ( prefix-spec private? -- ) help-coverage. ; diff --git a/extra/help/lint/coverage/summary.txt b/extra/help/lint/coverage/summary.txt new file mode 100644 index 0000000000..7b8e1cf8c3 --- /dev/null +++ b/extra/help/lint/coverage/summary.txt @@ -0,0 +1 @@ +Documentation coverage linter diff --git a/extra/help/lint/coverage/tags.txt b/extra/help/lint/coverage/tags.txt new file mode 100644 index 0000000000..ef1aab0d0e --- /dev/null +++ b/extra/help/lint/coverage/tags.txt @@ -0,0 +1 @@ +tools diff --git a/extra/machine-learning/data-sets/data-sets.factor b/extra/machine-learning/data-sets/data-sets.factor index 9bf7d482a9..018c4856c9 100644 --- a/extra/machine-learning/data-sets/data-sets.factor +++ b/extra/machine-learning/data-sets/data-sets.factor @@ -7,7 +7,7 @@ kernel math.parser sequences splitting ; IN: machine-learning.data-sets TUPLE: data-set data target target-names description -feature-names ; + feature-names ; C: data-set @@ -17,18 +17,30 @@ C: data-set "resource:extra/machine-learning/data-sets/" prepend utf8 file-contents ; +: load-tabular-file ( name -- lines ) + load-file [ blank? ] trim string-lines + [ [ blank? ] split-when harvest ] map harvest ; + : numerify ( table -- data names ) unclip [ [ [ string>number ] map ] map ] dip ; : load-table ( name -- data names ) - load-file [ blank? ] trim string-lines - [ [ blank? ] split-when ] map numerify ; + load-tabular-file numerify ; : load-table-csv ( name -- data names ) load-file string>csv numerify ; PRIVATE> +: load-monks ( name -- data-set ) + load-tabular-file + ! Omits the identifiers which are not so interesting. + [ but-last [ string>number ] map ] map + [ [ rest ] map ] [ [ first ] map ] bi + { "no" "yes" } + "monks.names" load-file + { "a1" "a2" "a3" "a4" "a5" "a6" } ; + : load-iris ( -- data-set ) "iris.csv" load-table-csv [ [ unclip-last ] { } map>assoc unzip ] [ 2 tail ] bi* diff --git a/extra/machine-learning/data-sets/monks-1.test b/extra/machine-learning/data-sets/monks-1.test new file mode 100644 index 0000000000..1f892d803f --- /dev/null +++ b/extra/machine-learning/data-sets/monks-1.test @@ -0,0 +1,432 @@ + 1 1 1 1 1 1 1 data_1 + 1 1 1 1 1 1 2 data_2 + 1 1 1 1 1 2 1 data_3 + 1 1 1 1 1 2 2 data_4 + 1 1 1 1 1 3 1 data_5 + 1 1 1 1 1 3 2 data_6 + 1 1 1 1 1 4 1 data_7 + 1 1 1 1 1 4 2 data_8 + 1 1 1 1 2 1 1 data_9 + 1 1 1 1 2 1 2 data_10 + 1 1 1 1 2 2 1 data_11 + 1 1 1 1 2 2 2 data_12 + 1 1 1 1 2 3 1 data_13 + 1 1 1 1 2 3 2 data_14 + 1 1 1 1 2 4 1 data_15 + 1 1 1 1 2 4 2 data_16 + 1 1 1 1 3 1 1 data_17 + 1 1 1 1 3 1 2 data_18 + 1 1 1 1 3 2 1 data_19 + 1 1 1 1 3 2 2 data_20 + 1 1 1 1 3 3 1 data_21 + 1 1 1 1 3 3 2 data_22 + 1 1 1 1 3 4 1 data_23 + 1 1 1 1 3 4 2 data_24 + 1 1 1 2 1 1 1 data_25 + 1 1 1 2 1 1 2 data_26 + 1 1 1 2 1 2 1 data_27 + 1 1 1 2 1 2 2 data_28 + 1 1 1 2 1 3 1 data_29 + 1 1 1 2 1 3 2 data_30 + 1 1 1 2 1 4 1 data_31 + 1 1 1 2 1 4 2 data_32 + 1 1 1 2 2 1 1 data_33 + 1 1 1 2 2 1 2 data_34 + 1 1 1 2 2 2 1 data_35 + 1 1 1 2 2 2 2 data_36 + 1 1 1 2 2 3 1 data_37 + 1 1 1 2 2 3 2 data_38 + 1 1 1 2 2 4 1 data_39 + 1 1 1 2 2 4 2 data_40 + 1 1 1 2 3 1 1 data_41 + 1 1 1 2 3 1 2 data_42 + 1 1 1 2 3 2 1 data_43 + 1 1 1 2 3 2 2 data_44 + 1 1 1 2 3 3 1 data_45 + 1 1 1 2 3 3 2 data_46 + 1 1 1 2 3 4 1 data_47 + 1 1 1 2 3 4 2 data_48 + 1 1 2 1 1 1 1 data_49 + 1 1 2 1 1 1 2 data_50 + 0 1 2 1 1 2 1 data_51 + 0 1 2 1 1 2 2 data_52 + 0 1 2 1 1 3 1 data_53 + 0 1 2 1 1 3 2 data_54 + 0 1 2 1 1 4 1 data_55 + 0 1 2 1 1 4 2 data_56 + 1 1 2 1 2 1 1 data_57 + 1 1 2 1 2 1 2 data_58 + 0 1 2 1 2 2 1 data_59 + 0 1 2 1 2 2 2 data_60 + 0 1 2 1 2 3 1 data_61 + 0 1 2 1 2 3 2 data_62 + 0 1 2 1 2 4 1 data_63 + 0 1 2 1 2 4 2 data_64 + 1 1 2 1 3 1 1 data_65 + 1 1 2 1 3 1 2 data_66 + 0 1 2 1 3 2 1 data_67 + 0 1 2 1 3 2 2 data_68 + 0 1 2 1 3 3 1 data_69 + 0 1 2 1 3 3 2 data_70 + 0 1 2 1 3 4 1 data_71 + 0 1 2 1 3 4 2 data_72 + 1 1 2 2 1 1 1 data_73 + 1 1 2 2 1 1 2 data_74 + 0 1 2 2 1 2 1 data_75 + 0 1 2 2 1 2 2 data_76 + 0 1 2 2 1 3 1 data_77 + 0 1 2 2 1 3 2 data_78 + 0 1 2 2 1 4 1 data_79 + 0 1 2 2 1 4 2 data_80 + 1 1 2 2 2 1 1 data_81 + 1 1 2 2 2 1 2 data_82 + 0 1 2 2 2 2 1 data_83 + 0 1 2 2 2 2 2 data_84 + 0 1 2 2 2 3 1 data_85 + 0 1 2 2 2 3 2 data_86 + 0 1 2 2 2 4 1 data_87 + 0 1 2 2 2 4 2 data_88 + 1 1 2 2 3 1 1 data_89 + 1 1 2 2 3 1 2 data_90 + 0 1 2 2 3 2 1 data_91 + 0 1 2 2 3 2 2 data_92 + 0 1 2 2 3 3 1 data_93 + 0 1 2 2 3 3 2 data_94 + 0 1 2 2 3 4 1 data_95 + 0 1 2 2 3 4 2 data_96 + 1 1 3 1 1 1 1 data_97 + 1 1 3 1 1 1 2 data_98 + 0 1 3 1 1 2 1 data_99 + 0 1 3 1 1 2 2 data_100 + 0 1 3 1 1 3 1 data_101 + 0 1 3 1 1 3 2 data_102 + 0 1 3 1 1 4 1 data_103 + 0 1 3 1 1 4 2 data_104 + 1 1 3 1 2 1 1 data_105 + 1 1 3 1 2 1 2 data_106 + 0 1 3 1 2 2 1 data_107 + 0 1 3 1 2 2 2 data_108 + 0 1 3 1 2 3 1 data_109 + 0 1 3 1 2 3 2 data_110 + 0 1 3 1 2 4 1 data_111 + 0 1 3 1 2 4 2 data_112 + 1 1 3 1 3 1 1 data_113 + 1 1 3 1 3 1 2 data_114 + 0 1 3 1 3 2 1 data_115 + 0 1 3 1 3 2 2 data_116 + 0 1 3 1 3 3 1 data_117 + 0 1 3 1 3 3 2 data_118 + 0 1 3 1 3 4 1 data_119 + 0 1 3 1 3 4 2 data_120 + 1 1 3 2 1 1 1 data_121 + 1 1 3 2 1 1 2 data_122 + 0 1 3 2 1 2 1 data_123 + 0 1 3 2 1 2 2 data_124 + 0 1 3 2 1 3 1 data_125 + 0 1 3 2 1 3 2 data_126 + 0 1 3 2 1 4 1 data_127 + 0 1 3 2 1 4 2 data_128 + 1 1 3 2 2 1 1 data_129 + 1 1 3 2 2 1 2 data_130 + 0 1 3 2 2 2 1 data_131 + 0 1 3 2 2 2 2 data_132 + 0 1 3 2 2 3 1 data_133 + 0 1 3 2 2 3 2 data_134 + 0 1 3 2 2 4 1 data_135 + 0 1 3 2 2 4 2 data_136 + 1 1 3 2 3 1 1 data_137 + 1 1 3 2 3 1 2 data_138 + 0 1 3 2 3 2 1 data_139 + 0 1 3 2 3 2 2 data_140 + 0 1 3 2 3 3 1 data_141 + 0 1 3 2 3 3 2 data_142 + 0 1 3 2 3 4 1 data_143 + 0 1 3 2 3 4 2 data_144 + 1 2 1 1 1 1 1 data_145 + 1 2 1 1 1 1 2 data_146 + 0 2 1 1 1 2 1 data_147 + 0 2 1 1 1 2 2 data_148 + 0 2 1 1 1 3 1 data_149 + 0 2 1 1 1 3 2 data_150 + 0 2 1 1 1 4 1 data_151 + 0 2 1 1 1 4 2 data_152 + 1 2 1 1 2 1 1 data_153 + 1 2 1 1 2 1 2 data_154 + 0 2 1 1 2 2 1 data_155 + 0 2 1 1 2 2 2 data_156 + 0 2 1 1 2 3 1 data_157 + 0 2 1 1 2 3 2 data_158 + 0 2 1 1 2 4 1 data_159 + 0 2 1 1 2 4 2 data_160 + 1 2 1 1 3 1 1 data_161 + 1 2 1 1 3 1 2 data_162 + 0 2 1 1 3 2 1 data_163 + 0 2 1 1 3 2 2 data_164 + 0 2 1 1 3 3 1 data_165 + 0 2 1 1 3 3 2 data_166 + 0 2 1 1 3 4 1 data_167 + 0 2 1 1 3 4 2 data_168 + 1 2 1 2 1 1 1 data_169 + 1 2 1 2 1 1 2 data_170 + 0 2 1 2 1 2 1 data_171 + 0 2 1 2 1 2 2 data_172 + 0 2 1 2 1 3 1 data_173 + 0 2 1 2 1 3 2 data_174 + 0 2 1 2 1 4 1 data_175 + 0 2 1 2 1 4 2 data_176 + 1 2 1 2 2 1 1 data_177 + 1 2 1 2 2 1 2 data_178 + 0 2 1 2 2 2 1 data_179 + 0 2 1 2 2 2 2 data_180 + 0 2 1 2 2 3 1 data_181 + 0 2 1 2 2 3 2 data_182 + 0 2 1 2 2 4 1 data_183 + 0 2 1 2 2 4 2 data_184 + 1 2 1 2 3 1 1 data_185 + 1 2 1 2 3 1 2 data_186 + 0 2 1 2 3 2 1 data_187 + 0 2 1 2 3 2 2 data_188 + 0 2 1 2 3 3 1 data_189 + 0 2 1 2 3 3 2 data_190 + 0 2 1 2 3 4 1 data_191 + 0 2 1 2 3 4 2 data_192 + 1 2 2 1 1 1 1 data_193 + 1 2 2 1 1 1 2 data_194 + 1 2 2 1 1 2 1 data_195 + 1 2 2 1 1 2 2 data_196 + 1 2 2 1 1 3 1 data_197 + 1 2 2 1 1 3 2 data_198 + 1 2 2 1 1 4 1 data_199 + 1 2 2 1 1 4 2 data_200 + 1 2 2 1 2 1 1 data_201 + 1 2 2 1 2 1 2 data_202 + 1 2 2 1 2 2 1 data_203 + 1 2 2 1 2 2 2 data_204 + 1 2 2 1 2 3 1 data_205 + 1 2 2 1 2 3 2 data_206 + 1 2 2 1 2 4 1 data_207 + 1 2 2 1 2 4 2 data_208 + 1 2 2 1 3 1 1 data_209 + 1 2 2 1 3 1 2 data_210 + 1 2 2 1 3 2 1 data_211 + 1 2 2 1 3 2 2 data_212 + 1 2 2 1 3 3 1 data_213 + 1 2 2 1 3 3 2 data_214 + 1 2 2 1 3 4 1 data_215 + 1 2 2 1 3 4 2 data_216 + 1 2 2 2 1 1 1 data_217 + 1 2 2 2 1 1 2 data_218 + 1 2 2 2 1 2 1 data_219 + 1 2 2 2 1 2 2 data_220 + 1 2 2 2 1 3 1 data_221 + 1 2 2 2 1 3 2 data_222 + 1 2 2 2 1 4 1 data_223 + 1 2 2 2 1 4 2 data_224 + 1 2 2 2 2 1 1 data_225 + 1 2 2 2 2 1 2 data_226 + 1 2 2 2 2 2 1 data_227 + 1 2 2 2 2 2 2 data_228 + 1 2 2 2 2 3 1 data_229 + 1 2 2 2 2 3 2 data_230 + 1 2 2 2 2 4 1 data_231 + 1 2 2 2 2 4 2 data_232 + 1 2 2 2 3 1 1 data_233 + 1 2 2 2 3 1 2 data_234 + 1 2 2 2 3 2 1 data_235 + 1 2 2 2 3 2 2 data_236 + 1 2 2 2 3 3 1 data_237 + 1 2 2 2 3 3 2 data_238 + 1 2 2 2 3 4 1 data_239 + 1 2 2 2 3 4 2 data_240 + 1 2 3 1 1 1 1 data_241 + 1 2 3 1 1 1 2 data_242 + 0 2 3 1 1 2 1 data_243 + 0 2 3 1 1 2 2 data_244 + 0 2 3 1 1 3 1 data_245 + 0 2 3 1 1 3 2 data_246 + 0 2 3 1 1 4 1 data_247 + 0 2 3 1 1 4 2 data_248 + 1 2 3 1 2 1 1 data_249 + 1 2 3 1 2 1 2 data_250 + 0 2 3 1 2 2 1 data_251 + 0 2 3 1 2 2 2 data_252 + 0 2 3 1 2 3 1 data_253 + 0 2 3 1 2 3 2 data_254 + 0 2 3 1 2 4 1 data_255 + 0 2 3 1 2 4 2 data_256 + 1 2 3 1 3 1 1 data_257 + 1 2 3 1 3 1 2 data_258 + 0 2 3 1 3 2 1 data_259 + 0 2 3 1 3 2 2 data_260 + 0 2 3 1 3 3 1 data_261 + 0 2 3 1 3 3 2 data_262 + 0 2 3 1 3 4 1 data_263 + 0 2 3 1 3 4 2 data_264 + 1 2 3 2 1 1 1 data_265 + 1 2 3 2 1 1 2 data_266 + 0 2 3 2 1 2 1 data_267 + 0 2 3 2 1 2 2 data_268 + 0 2 3 2 1 3 1 data_269 + 0 2 3 2 1 3 2 data_270 + 0 2 3 2 1 4 1 data_271 + 0 2 3 2 1 4 2 data_272 + 1 2 3 2 2 1 1 data_273 + 1 2 3 2 2 1 2 data_274 + 0 2 3 2 2 2 1 data_275 + 0 2 3 2 2 2 2 data_276 + 0 2 3 2 2 3 1 data_277 + 0 2 3 2 2 3 2 data_278 + 0 2 3 2 2 4 1 data_279 + 0 2 3 2 2 4 2 data_280 + 1 2 3 2 3 1 1 data_281 + 1 2 3 2 3 1 2 data_282 + 0 2 3 2 3 2 1 data_283 + 0 2 3 2 3 2 2 data_284 + 0 2 3 2 3 3 1 data_285 + 0 2 3 2 3 3 2 data_286 + 0 2 3 2 3 4 1 data_287 + 0 2 3 2 3 4 2 data_288 + 1 3 1 1 1 1 1 data_289 + 1 3 1 1 1 1 2 data_290 + 0 3 1 1 1 2 1 data_291 + 0 3 1 1 1 2 2 data_292 + 0 3 1 1 1 3 1 data_293 + 0 3 1 1 1 3 2 data_294 + 0 3 1 1 1 4 1 data_295 + 0 3 1 1 1 4 2 data_296 + 1 3 1 1 2 1 1 data_297 + 1 3 1 1 2 1 2 data_298 + 0 3 1 1 2 2 1 data_299 + 0 3 1 1 2 2 2 data_300 + 0 3 1 1 2 3 1 data_301 + 0 3 1 1 2 3 2 data_302 + 0 3 1 1 2 4 1 data_303 + 0 3 1 1 2 4 2 data_304 + 1 3 1 1 3 1 1 data_305 + 1 3 1 1 3 1 2 data_306 + 0 3 1 1 3 2 1 data_307 + 0 3 1 1 3 2 2 data_308 + 0 3 1 1 3 3 1 data_309 + 0 3 1 1 3 3 2 data_310 + 0 3 1 1 3 4 1 data_311 + 0 3 1 1 3 4 2 data_312 + 1 3 1 2 1 1 1 data_313 + 1 3 1 2 1 1 2 data_314 + 0 3 1 2 1 2 1 data_315 + 0 3 1 2 1 2 2 data_316 + 0 3 1 2 1 3 1 data_317 + 0 3 1 2 1 3 2 data_318 + 0 3 1 2 1 4 1 data_319 + 0 3 1 2 1 4 2 data_320 + 1 3 1 2 2 1 1 data_321 + 1 3 1 2 2 1 2 data_322 + 0 3 1 2 2 2 1 data_323 + 0 3 1 2 2 2 2 data_324 + 0 3 1 2 2 3 1 data_325 + 0 3 1 2 2 3 2 data_326 + 0 3 1 2 2 4 1 data_327 + 0 3 1 2 2 4 2 data_328 + 1 3 1 2 3 1 1 data_329 + 1 3 1 2 3 1 2 data_330 + 0 3 1 2 3 2 1 data_331 + 0 3 1 2 3 2 2 data_332 + 0 3 1 2 3 3 1 data_333 + 0 3 1 2 3 3 2 data_334 + 0 3 1 2 3 4 1 data_335 + 0 3 1 2 3 4 2 data_336 + 1 3 2 1 1 1 1 data_337 + 1 3 2 1 1 1 2 data_338 + 0 3 2 1 1 2 1 data_339 + 0 3 2 1 1 2 2 data_340 + 0 3 2 1 1 3 1 data_341 + 0 3 2 1 1 3 2 data_342 + 0 3 2 1 1 4 1 data_343 + 0 3 2 1 1 4 2 data_344 + 1 3 2 1 2 1 1 data_345 + 1 3 2 1 2 1 2 data_346 + 0 3 2 1 2 2 1 data_347 + 0 3 2 1 2 2 2 data_348 + 0 3 2 1 2 3 1 data_349 + 0 3 2 1 2 3 2 data_350 + 0 3 2 1 2 4 1 data_351 + 0 3 2 1 2 4 2 data_352 + 1 3 2 1 3 1 1 data_353 + 1 3 2 1 3 1 2 data_354 + 0 3 2 1 3 2 1 data_355 + 0 3 2 1 3 2 2 data_356 + 0 3 2 1 3 3 1 data_357 + 0 3 2 1 3 3 2 data_358 + 0 3 2 1 3 4 1 data_359 + 0 3 2 1 3 4 2 data_360 + 1 3 2 2 1 1 1 data_361 + 1 3 2 2 1 1 2 data_362 + 0 3 2 2 1 2 1 data_363 + 0 3 2 2 1 2 2 data_364 + 0 3 2 2 1 3 1 data_365 + 0 3 2 2 1 3 2 data_366 + 0 3 2 2 1 4 1 data_367 + 0 3 2 2 1 4 2 data_368 + 1 3 2 2 2 1 1 data_369 + 1 3 2 2 2 1 2 data_370 + 0 3 2 2 2 2 1 data_371 + 0 3 2 2 2 2 2 data_372 + 0 3 2 2 2 3 1 data_373 + 0 3 2 2 2 3 2 data_374 + 0 3 2 2 2 4 1 data_375 + 0 3 2 2 2 4 2 data_376 + 1 3 2 2 3 1 1 data_377 + 1 3 2 2 3 1 2 data_378 + 0 3 2 2 3 2 1 data_379 + 0 3 2 2 3 2 2 data_380 + 0 3 2 2 3 3 1 data_381 + 0 3 2 2 3 3 2 data_382 + 0 3 2 2 3 4 1 data_383 + 0 3 2 2 3 4 2 data_384 + 1 3 3 1 1 1 1 data_385 + 1 3 3 1 1 1 2 data_386 + 1 3 3 1 1 2 1 data_387 + 1 3 3 1 1 2 2 data_388 + 1 3 3 1 1 3 1 data_389 + 1 3 3 1 1 3 2 data_390 + 1 3 3 1 1 4 1 data_391 + 1 3 3 1 1 4 2 data_392 + 1 3 3 1 2 1 1 data_393 + 1 3 3 1 2 1 2 data_394 + 1 3 3 1 2 2 1 data_395 + 1 3 3 1 2 2 2 data_396 + 1 3 3 1 2 3 1 data_397 + 1 3 3 1 2 3 2 data_398 + 1 3 3 1 2 4 1 data_399 + 1 3 3 1 2 4 2 data_400 + 1 3 3 1 3 1 1 data_401 + 1 3 3 1 3 1 2 data_402 + 1 3 3 1 3 2 1 data_403 + 1 3 3 1 3 2 2 data_404 + 1 3 3 1 3 3 1 data_405 + 1 3 3 1 3 3 2 data_406 + 1 3 3 1 3 4 1 data_407 + 1 3 3 1 3 4 2 data_408 + 1 3 3 2 1 1 1 data_409 + 1 3 3 2 1 1 2 data_410 + 1 3 3 2 1 2 1 data_411 + 1 3 3 2 1 2 2 data_412 + 1 3 3 2 1 3 1 data_413 + 1 3 3 2 1 3 2 data_414 + 1 3 3 2 1 4 1 data_415 + 1 3 3 2 1 4 2 data_416 + 1 3 3 2 2 1 1 data_417 + 1 3 3 2 2 1 2 data_418 + 1 3 3 2 2 2 1 data_419 + 1 3 3 2 2 2 2 data_420 + 1 3 3 2 2 3 1 data_421 + 1 3 3 2 2 3 2 data_422 + 1 3 3 2 2 4 1 data_423 + 1 3 3 2 2 4 2 data_424 + 1 3 3 2 3 1 1 data_425 + 1 3 3 2 3 1 2 data_426 + 1 3 3 2 3 2 1 data_427 + 1 3 3 2 3 2 2 data_428 + 1 3 3 2 3 3 1 data_429 + 1 3 3 2 3 3 2 data_430 + 1 3 3 2 3 4 1 data_431 + 1 3 3 2 3 4 2 data_432 diff --git a/extra/machine-learning/data-sets/monks-1.train b/extra/machine-learning/data-sets/monks-1.train new file mode 100644 index 0000000000..5a540db5a3 --- /dev/null +++ b/extra/machine-learning/data-sets/monks-1.train @@ -0,0 +1,124 @@ + 1 1 1 1 1 3 1 data_5 + 1 1 1 1 1 3 2 data_6 + 1 1 1 1 3 2 1 data_19 + 1 1 1 1 3 3 2 data_22 + 1 1 1 2 1 2 1 data_27 + 1 1 1 2 1 2 2 data_28 + 1 1 1 2 2 3 1 data_37 + 1 1 1 2 2 4 1 data_39 + 1 1 1 2 3 1 2 data_42 + 1 1 2 1 1 1 2 data_50 + 0 1 2 1 1 2 1 data_51 + 0 1 2 1 1 3 1 data_53 + 0 1 2 1 1 4 2 data_56 + 1 1 2 1 2 1 1 data_57 + 0 1 2 1 2 3 1 data_61 + 0 1 2 1 2 3 2 data_62 + 0 1 2 1 2 4 2 data_64 + 0 1 2 1 3 2 1 data_67 + 0 1 2 1 3 4 2 data_72 + 0 1 2 2 1 2 2 data_76 + 0 1 2 2 2 3 2 data_86 + 0 1 2 2 2 4 1 data_87 + 0 1 2 2 2 4 2 data_88 + 0 1 2 2 3 2 2 data_92 + 0 1 2 2 3 3 1 data_93 + 0 1 2 2 3 3 2 data_94 + 0 1 3 1 1 2 1 data_99 + 0 1 3 1 1 4 1 data_103 + 0 1 3 1 2 2 1 data_107 + 0 1 3 1 2 4 1 data_111 + 1 1 3 1 3 1 2 data_114 + 0 1 3 1 3 2 2 data_116 + 0 1 3 1 3 3 1 data_117 + 0 1 3 1 3 4 1 data_119 + 0 1 3 1 3 4 2 data_120 + 0 1 3 2 1 2 2 data_124 + 1 1 3 2 2 1 2 data_130 + 0 1 3 2 2 2 2 data_132 + 0 1 3 2 2 3 2 data_134 + 0 1 3 2 2 4 1 data_135 + 0 1 3 2 2 4 2 data_136 + 1 1 3 2 3 1 1 data_137 + 0 1 3 2 3 2 1 data_139 + 0 1 3 2 3 4 1 data_143 + 0 1 3 2 3 4 2 data_144 + 0 2 1 1 1 3 1 data_149 + 0 2 1 1 1 3 2 data_150 + 1 2 1 1 2 1 1 data_153 + 1 2 1 1 2 1 2 data_154 + 0 2 1 1 2 2 2 data_156 + 0 2 1 1 2 3 1 data_157 + 0 2 1 1 2 4 1 data_159 + 0 2 1 1 2 4 2 data_160 + 0 2 1 1 3 4 1 data_167 + 0 2 1 2 1 2 2 data_172 + 0 2 1 2 1 3 1 data_173 + 0 2 1 2 1 4 2 data_176 + 0 2 1 2 2 3 1 data_181 + 0 2 1 2 2 4 2 data_184 + 0 2 1 2 3 2 2 data_188 + 0 2 1 2 3 4 1 data_191 + 1 2 2 1 1 2 1 data_195 + 1 2 2 1 1 2 2 data_196 + 1 2 2 1 1 3 1 data_197 + 1 2 2 1 2 3 2 data_206 + 1 2 2 1 3 1 1 data_209 + 1 2 2 1 3 1 2 data_210 + 1 2 2 1 3 2 2 data_212 + 1 2 2 1 3 3 2 data_214 + 1 2 2 1 3 4 2 data_216 + 1 2 2 2 1 1 1 data_217 + 1 2 2 2 1 3 2 data_222 + 1 2 2 2 1 4 1 data_223 + 1 2 2 2 1 4 2 data_224 + 1 2 2 2 2 2 1 data_227 + 1 2 2 2 3 4 1 data_239 + 1 2 3 1 1 1 1 data_241 + 1 2 3 1 2 1 1 data_249 + 0 2 3 1 2 3 1 data_253 + 1 2 3 1 3 1 2 data_258 + 0 2 3 1 3 3 1 data_261 + 0 2 3 1 3 4 2 data_264 + 0 2 3 2 1 3 2 data_270 + 1 2 3 2 2 1 1 data_273 + 1 2 3 2 2 1 2 data_274 + 0 2 3 2 2 2 1 data_275 + 0 2 3 2 3 3 2 data_286 + 1 3 1 1 1 1 1 data_289 + 1 3 1 1 1 1 2 data_290 + 1 3 1 1 2 1 1 data_297 + 0 3 1 1 2 2 2 data_300 + 0 3 1 1 3 2 2 data_308 + 1 3 1 2 1 1 1 data_313 + 0 3 1 2 1 2 2 data_316 + 0 3 1 2 2 2 2 data_324 + 0 3 1 2 2 3 2 data_326 + 0 3 1 2 3 2 2 data_332 + 1 3 2 1 1 1 1 data_337 + 0 3 2 1 1 4 2 data_344 + 1 3 2 1 2 1 2 data_346 + 0 3 2 1 2 4 2 data_352 + 1 3 2 2 1 1 1 data_361 + 1 3 2 2 1 1 2 data_362 + 0 3 2 2 1 3 2 data_366 + 1 3 2 2 3 1 1 data_377 + 0 3 2 2 3 2 1 data_379 + 0 3 2 2 3 4 1 data_383 + 1 3 3 1 1 1 1 data_385 + 1 3 3 1 1 2 1 data_387 + 1 3 3 1 1 4 2 data_392 + 1 3 3 1 2 3 2 data_398 + 1 3 3 1 2 4 2 data_400 + 1 3 3 1 3 1 2 data_402 + 1 3 3 1 3 2 1 data_403 + 1 3 3 1 3 2 2 data_404 + 1 3 3 1 3 4 2 data_408 + 1 3 3 2 1 1 1 data_409 + 1 3 3 2 1 3 2 data_414 + 1 3 3 2 1 4 1 data_415 + 1 3 3 2 1 4 2 data_416 + 1 3 3 2 3 1 2 data_426 + 1 3 3 2 3 2 2 data_428 + 1 3 3 2 3 3 2 data_430 + 1 3 3 2 3 4 2 data_432 diff --git a/extra/machine-learning/data-sets/monks-2.test b/extra/machine-learning/data-sets/monks-2.test new file mode 100644 index 0000000000..44a1f13cf3 --- /dev/null +++ b/extra/machine-learning/data-sets/monks-2.test @@ -0,0 +1,432 @@ + 0 1 1 1 1 1 1 data_1 + 0 1 1 1 1 1 2 data_2 + 0 1 1 1 1 2 1 data_3 + 0 1 1 1 1 2 2 data_4 + 0 1 1 1 1 3 1 data_5 + 0 1 1 1 1 3 2 data_6 + 0 1 1 1 1 4 1 data_7 + 0 1 1 1 1 4 2 data_8 + 0 1 1 1 2 1 1 data_9 + 0 1 1 1 2 1 2 data_10 + 0 1 1 1 2 2 1 data_11 + 0 1 1 1 2 2 2 data_12 + 0 1 1 1 2 3 1 data_13 + 0 1 1 1 2 3 2 data_14 + 0 1 1 1 2 4 1 data_15 + 0 1 1 1 2 4 2 data_16 + 0 1 1 1 3 1 1 data_17 + 0 1 1 1 3 1 2 data_18 + 0 1 1 1 3 2 1 data_19 + 0 1 1 1 3 2 2 data_20 + 0 1 1 1 3 3 1 data_21 + 0 1 1 1 3 3 2 data_22 + 0 1 1 1 3 4 1 data_23 + 0 1 1 1 3 4 2 data_24 + 0 1 1 2 1 1 1 data_25 + 0 1 1 2 1 1 2 data_26 + 0 1 1 2 1 2 1 data_27 + 0 1 1 2 1 2 2 data_28 + 0 1 1 2 1 3 1 data_29 + 0 1 1 2 1 3 2 data_30 + 0 1 1 2 1 4 1 data_31 + 0 1 1 2 1 4 2 data_32 + 0 1 1 2 2 1 1 data_33 + 0 1 1 2 2 1 2 data_34 + 0 1 1 2 2 2 1 data_35 + 1 1 1 2 2 2 2 data_36 + 0 1 1 2 2 3 1 data_37 + 1 1 1 2 2 3 2 data_38 + 0 1 1 2 2 4 1 data_39 + 1 1 1 2 2 4 2 data_40 + 0 1 1 2 3 1 1 data_41 + 0 1 1 2 3 1 2 data_42 + 0 1 1 2 3 2 1 data_43 + 1 1 1 2 3 2 2 data_44 + 0 1 1 2 3 3 1 data_45 + 1 1 1 2 3 3 2 data_46 + 0 1 1 2 3 4 1 data_47 + 1 1 1 2 3 4 2 data_48 + 0 1 2 1 1 1 1 data_49 + 0 1 2 1 1 1 2 data_50 + 0 1 2 1 1 2 1 data_51 + 0 1 2 1 1 2 2 data_52 + 0 1 2 1 1 3 1 data_53 + 0 1 2 1 1 3 2 data_54 + 0 1 2 1 1 4 1 data_55 + 0 1 2 1 1 4 2 data_56 + 0 1 2 1 2 1 1 data_57 + 0 1 2 1 2 1 2 data_58 + 0 1 2 1 2 2 1 data_59 + 1 1 2 1 2 2 2 data_60 + 0 1 2 1 2 3 1 data_61 + 1 1 2 1 2 3 2 data_62 + 0 1 2 1 2 4 1 data_63 + 1 1 2 1 2 4 2 data_64 + 0 1 2 1 3 1 1 data_65 + 0 1 2 1 3 1 2 data_66 + 0 1 2 1 3 2 1 data_67 + 1 1 2 1 3 2 2 data_68 + 0 1 2 1 3 3 1 data_69 + 1 1 2 1 3 3 2 data_70 + 0 1 2 1 3 4 1 data_71 + 1 1 2 1 3 4 2 data_72 + 0 1 2 2 1 1 1 data_73 + 0 1 2 2 1 1 2 data_74 + 0 1 2 2 1 2 1 data_75 + 1 1 2 2 1 2 2 data_76 + 0 1 2 2 1 3 1 data_77 + 1 1 2 2 1 3 2 data_78 + 0 1 2 2 1 4 1 data_79 + 1 1 2 2 1 4 2 data_80 + 0 1 2 2 2 1 1 data_81 + 1 1 2 2 2 1 2 data_82 + 1 1 2 2 2 2 1 data_83 + 0 1 2 2 2 2 2 data_84 + 1 1 2 2 2 3 1 data_85 + 0 1 2 2 2 3 2 data_86 + 1 1 2 2 2 4 1 data_87 + 0 1 2 2 2 4 2 data_88 + 0 1 2 2 3 1 1 data_89 + 1 1 2 2 3 1 2 data_90 + 1 1 2 2 3 2 1 data_91 + 0 1 2 2 3 2 2 data_92 + 1 1 2 2 3 3 1 data_93 + 0 1 2 2 3 3 2 data_94 + 1 1 2 2 3 4 1 data_95 + 0 1 2 2 3 4 2 data_96 + 0 1 3 1 1 1 1 data_97 + 0 1 3 1 1 1 2 data_98 + 0 1 3 1 1 2 1 data_99 + 0 1 3 1 1 2 2 data_100 + 0 1 3 1 1 3 1 data_101 + 0 1 3 1 1 3 2 data_102 + 0 1 3 1 1 4 1 data_103 + 0 1 3 1 1 4 2 data_104 + 0 1 3 1 2 1 1 data_105 + 0 1 3 1 2 1 2 data_106 + 0 1 3 1 2 2 1 data_107 + 1 1 3 1 2 2 2 data_108 + 0 1 3 1 2 3 1 data_109 + 1 1 3 1 2 3 2 data_110 + 0 1 3 1 2 4 1 data_111 + 1 1 3 1 2 4 2 data_112 + 0 1 3 1 3 1 1 data_113 + 0 1 3 1 3 1 2 data_114 + 0 1 3 1 3 2 1 data_115 + 1 1 3 1 3 2 2 data_116 + 0 1 3 1 3 3 1 data_117 + 1 1 3 1 3 3 2 data_118 + 0 1 3 1 3 4 1 data_119 + 1 1 3 1 3 4 2 data_120 + 0 1 3 2 1 1 1 data_121 + 0 1 3 2 1 1 2 data_122 + 0 1 3 2 1 2 1 data_123 + 1 1 3 2 1 2 2 data_124 + 0 1 3 2 1 3 1 data_125 + 1 1 3 2 1 3 2 data_126 + 0 1 3 2 1 4 1 data_127 + 1 1 3 2 1 4 2 data_128 + 0 1 3 2 2 1 1 data_129 + 1 1 3 2 2 1 2 data_130 + 1 1 3 2 2 2 1 data_131 + 0 1 3 2 2 2 2 data_132 + 1 1 3 2 2 3 1 data_133 + 0 1 3 2 2 3 2 data_134 + 1 1 3 2 2 4 1 data_135 + 0 1 3 2 2 4 2 data_136 + 0 1 3 2 3 1 1 data_137 + 1 1 3 2 3 1 2 data_138 + 1 1 3 2 3 2 1 data_139 + 0 1 3 2 3 2 2 data_140 + 1 1 3 2 3 3 1 data_141 + 0 1 3 2 3 3 2 data_142 + 1 1 3 2 3 4 1 data_143 + 0 1 3 2 3 4 2 data_144 + 0 2 1 1 1 1 1 data_145 + 0 2 1 1 1 1 2 data_146 + 0 2 1 1 1 2 1 data_147 + 0 2 1 1 1 2 2 data_148 + 0 2 1 1 1 3 1 data_149 + 0 2 1 1 1 3 2 data_150 + 0 2 1 1 1 4 1 data_151 + 0 2 1 1 1 4 2 data_152 + 0 2 1 1 2 1 1 data_153 + 0 2 1 1 2 1 2 data_154 + 0 2 1 1 2 2 1 data_155 + 1 2 1 1 2 2 2 data_156 + 0 2 1 1 2 3 1 data_157 + 1 2 1 1 2 3 2 data_158 + 0 2 1 1 2 4 1 data_159 + 1 2 1 1 2 4 2 data_160 + 0 2 1 1 3 1 1 data_161 + 0 2 1 1 3 1 2 data_162 + 0 2 1 1 3 2 1 data_163 + 1 2 1 1 3 2 2 data_164 + 0 2 1 1 3 3 1 data_165 + 1 2 1 1 3 3 2 data_166 + 0 2 1 1 3 4 1 data_167 + 1 2 1 1 3 4 2 data_168 + 0 2 1 2 1 1 1 data_169 + 0 2 1 2 1 1 2 data_170 + 0 2 1 2 1 2 1 data_171 + 1 2 1 2 1 2 2 data_172 + 0 2 1 2 1 3 1 data_173 + 1 2 1 2 1 3 2 data_174 + 0 2 1 2 1 4 1 data_175 + 1 2 1 2 1 4 2 data_176 + 0 2 1 2 2 1 1 data_177 + 1 2 1 2 2 1 2 data_178 + 1 2 1 2 2 2 1 data_179 + 0 2 1 2 2 2 2 data_180 + 1 2 1 2 2 3 1 data_181 + 0 2 1 2 2 3 2 data_182 + 1 2 1 2 2 4 1 data_183 + 0 2 1 2 2 4 2 data_184 + 0 2 1 2 3 1 1 data_185 + 1 2 1 2 3 1 2 data_186 + 1 2 1 2 3 2 1 data_187 + 0 2 1 2 3 2 2 data_188 + 1 2 1 2 3 3 1 data_189 + 0 2 1 2 3 3 2 data_190 + 1 2 1 2 3 4 1 data_191 + 0 2 1 2 3 4 2 data_192 + 0 2 2 1 1 1 1 data_193 + 0 2 2 1 1 1 2 data_194 + 0 2 2 1 1 2 1 data_195 + 1 2 2 1 1 2 2 data_196 + 0 2 2 1 1 3 1 data_197 + 1 2 2 1 1 3 2 data_198 + 0 2 2 1 1 4 1 data_199 + 1 2 2 1 1 4 2 data_200 + 0 2 2 1 2 1 1 data_201 + 1 2 2 1 2 1 2 data_202 + 1 2 2 1 2 2 1 data_203 + 0 2 2 1 2 2 2 data_204 + 1 2 2 1 2 3 1 data_205 + 0 2 2 1 2 3 2 data_206 + 1 2 2 1 2 4 1 data_207 + 0 2 2 1 2 4 2 data_208 + 0 2 2 1 3 1 1 data_209 + 1 2 2 1 3 1 2 data_210 + 1 2 2 1 3 2 1 data_211 + 0 2 2 1 3 2 2 data_212 + 1 2 2 1 3 3 1 data_213 + 0 2 2 1 3 3 2 data_214 + 1 2 2 1 3 4 1 data_215 + 0 2 2 1 3 4 2 data_216 + 0 2 2 2 1 1 1 data_217 + 1 2 2 2 1 1 2 data_218 + 1 2 2 2 1 2 1 data_219 + 0 2 2 2 1 2 2 data_220 + 1 2 2 2 1 3 1 data_221 + 0 2 2 2 1 3 2 data_222 + 1 2 2 2 1 4 1 data_223 + 0 2 2 2 1 4 2 data_224 + 1 2 2 2 2 1 1 data_225 + 0 2 2 2 2 1 2 data_226 + 0 2 2 2 2 2 1 data_227 + 0 2 2 2 2 2 2 data_228 + 0 2 2 2 2 3 1 data_229 + 0 2 2 2 2 3 2 data_230 + 0 2 2 2 2 4 1 data_231 + 0 2 2 2 2 4 2 data_232 + 1 2 2 2 3 1 1 data_233 + 0 2 2 2 3 1 2 data_234 + 0 2 2 2 3 2 1 data_235 + 0 2 2 2 3 2 2 data_236 + 0 2 2 2 3 3 1 data_237 + 0 2 2 2 3 3 2 data_238 + 0 2 2 2 3 4 1 data_239 + 0 2 2 2 3 4 2 data_240 + 0 2 3 1 1 1 1 data_241 + 0 2 3 1 1 1 2 data_242 + 0 2 3 1 1 2 1 data_243 + 1 2 3 1 1 2 2 data_244 + 0 2 3 1 1 3 1 data_245 + 1 2 3 1 1 3 2 data_246 + 0 2 3 1 1 4 1 data_247 + 1 2 3 1 1 4 2 data_248 + 0 2 3 1 2 1 1 data_249 + 1 2 3 1 2 1 2 data_250 + 1 2 3 1 2 2 1 data_251 + 0 2 3 1 2 2 2 data_252 + 1 2 3 1 2 3 1 data_253 + 0 2 3 1 2 3 2 data_254 + 1 2 3 1 2 4 1 data_255 + 0 2 3 1 2 4 2 data_256 + 0 2 3 1 3 1 1 data_257 + 1 2 3 1 3 1 2 data_258 + 1 2 3 1 3 2 1 data_259 + 0 2 3 1 3 2 2 data_260 + 1 2 3 1 3 3 1 data_261 + 0 2 3 1 3 3 2 data_262 + 1 2 3 1 3 4 1 data_263 + 0 2 3 1 3 4 2 data_264 + 0 2 3 2 1 1 1 data_265 + 1 2 3 2 1 1 2 data_266 + 1 2 3 2 1 2 1 data_267 + 0 2 3 2 1 2 2 data_268 + 1 2 3 2 1 3 1 data_269 + 0 2 3 2 1 3 2 data_270 + 1 2 3 2 1 4 1 data_271 + 0 2 3 2 1 4 2 data_272 + 1 2 3 2 2 1 1 data_273 + 0 2 3 2 2 1 2 data_274 + 0 2 3 2 2 2 1 data_275 + 0 2 3 2 2 2 2 data_276 + 0 2 3 2 2 3 1 data_277 + 0 2 3 2 2 3 2 data_278 + 0 2 3 2 2 4 1 data_279 + 0 2 3 2 2 4 2 data_280 + 1 2 3 2 3 1 1 data_281 + 0 2 3 2 3 1 2 data_282 + 0 2 3 2 3 2 1 data_283 + 0 2 3 2 3 2 2 data_284 + 0 2 3 2 3 3 1 data_285 + 0 2 3 2 3 3 2 data_286 + 0 2 3 2 3 4 1 data_287 + 0 2 3 2 3 4 2 data_288 + 0 3 1 1 1 1 1 data_289 + 0 3 1 1 1 1 2 data_290 + 0 3 1 1 1 2 1 data_291 + 0 3 1 1 1 2 2 data_292 + 0 3 1 1 1 3 1 data_293 + 0 3 1 1 1 3 2 data_294 + 0 3 1 1 1 4 1 data_295 + 0 3 1 1 1 4 2 data_296 + 0 3 1 1 2 1 1 data_297 + 0 3 1 1 2 1 2 data_298 + 0 3 1 1 2 2 1 data_299 + 1 3 1 1 2 2 2 data_300 + 0 3 1 1 2 3 1 data_301 + 1 3 1 1 2 3 2 data_302 + 0 3 1 1 2 4 1 data_303 + 1 3 1 1 2 4 2 data_304 + 0 3 1 1 3 1 1 data_305 + 0 3 1 1 3 1 2 data_306 + 0 3 1 1 3 2 1 data_307 + 1 3 1 1 3 2 2 data_308 + 0 3 1 1 3 3 1 data_309 + 1 3 1 1 3 3 2 data_310 + 0 3 1 1 3 4 1 data_311 + 1 3 1 1 3 4 2 data_312 + 0 3 1 2 1 1 1 data_313 + 0 3 1 2 1 1 2 data_314 + 0 3 1 2 1 2 1 data_315 + 1 3 1 2 1 2 2 data_316 + 0 3 1 2 1 3 1 data_317 + 1 3 1 2 1 3 2 data_318 + 0 3 1 2 1 4 1 data_319 + 1 3 1 2 1 4 2 data_320 + 0 3 1 2 2 1 1 data_321 + 1 3 1 2 2 1 2 data_322 + 1 3 1 2 2 2 1 data_323 + 0 3 1 2 2 2 2 data_324 + 1 3 1 2 2 3 1 data_325 + 0 3 1 2 2 3 2 data_326 + 1 3 1 2 2 4 1 data_327 + 0 3 1 2 2 4 2 data_328 + 0 3 1 2 3 1 1 data_329 + 1 3 1 2 3 1 2 data_330 + 1 3 1 2 3 2 1 data_331 + 0 3 1 2 3 2 2 data_332 + 1 3 1 2 3 3 1 data_333 + 0 3 1 2 3 3 2 data_334 + 1 3 1 2 3 4 1 data_335 + 0 3 1 2 3 4 2 data_336 + 0 3 2 1 1 1 1 data_337 + 0 3 2 1 1 1 2 data_338 + 0 3 2 1 1 2 1 data_339 + 1 3 2 1 1 2 2 data_340 + 0 3 2 1 1 3 1 data_341 + 1 3 2 1 1 3 2 data_342 + 0 3 2 1 1 4 1 data_343 + 1 3 2 1 1 4 2 data_344 + 0 3 2 1 2 1 1 data_345 + 1 3 2 1 2 1 2 data_346 + 1 3 2 1 2 2 1 data_347 + 0 3 2 1 2 2 2 data_348 + 1 3 2 1 2 3 1 data_349 + 0 3 2 1 2 3 2 data_350 + 1 3 2 1 2 4 1 data_351 + 0 3 2 1 2 4 2 data_352 + 0 3 2 1 3 1 1 data_353 + 1 3 2 1 3 1 2 data_354 + 1 3 2 1 3 2 1 data_355 + 0 3 2 1 3 2 2 data_356 + 1 3 2 1 3 3 1 data_357 + 0 3 2 1 3 3 2 data_358 + 1 3 2 1 3 4 1 data_359 + 0 3 2 1 3 4 2 data_360 + 0 3 2 2 1 1 1 data_361 + 1 3 2 2 1 1 2 data_362 + 1 3 2 2 1 2 1 data_363 + 0 3 2 2 1 2 2 data_364 + 1 3 2 2 1 3 1 data_365 + 0 3 2 2 1 3 2 data_366 + 1 3 2 2 1 4 1 data_367 + 0 3 2 2 1 4 2 data_368 + 1 3 2 2 2 1 1 data_369 + 0 3 2 2 2 1 2 data_370 + 0 3 2 2 2 2 1 data_371 + 0 3 2 2 2 2 2 data_372 + 0 3 2 2 2 3 1 data_373 + 0 3 2 2 2 3 2 data_374 + 0 3 2 2 2 4 1 data_375 + 0 3 2 2 2 4 2 data_376 + 1 3 2 2 3 1 1 data_377 + 0 3 2 2 3 1 2 data_378 + 0 3 2 2 3 2 1 data_379 + 0 3 2 2 3 2 2 data_380 + 0 3 2 2 3 3 1 data_381 + 0 3 2 2 3 3 2 data_382 + 0 3 2 2 3 4 1 data_383 + 0 3 2 2 3 4 2 data_384 + 0 3 3 1 1 1 1 data_385 + 0 3 3 1 1 1 2 data_386 + 0 3 3 1 1 2 1 data_387 + 1 3 3 1 1 2 2 data_388 + 0 3 3 1 1 3 1 data_389 + 1 3 3 1 1 3 2 data_390 + 0 3 3 1 1 4 1 data_391 + 1 3 3 1 1 4 2 data_392 + 0 3 3 1 2 1 1 data_393 + 1 3 3 1 2 1 2 data_394 + 1 3 3 1 2 2 1 data_395 + 0 3 3 1 2 2 2 data_396 + 1 3 3 1 2 3 1 data_397 + 0 3 3 1 2 3 2 data_398 + 1 3 3 1 2 4 1 data_399 + 0 3 3 1 2 4 2 data_400 + 0 3 3 1 3 1 1 data_401 + 1 3 3 1 3 1 2 data_402 + 1 3 3 1 3 2 1 data_403 + 0 3 3 1 3 2 2 data_404 + 1 3 3 1 3 3 1 data_405 + 0 3 3 1 3 3 2 data_406 + 1 3 3 1 3 4 1 data_407 + 0 3 3 1 3 4 2 data_408 + 0 3 3 2 1 1 1 data_409 + 1 3 3 2 1 1 2 data_410 + 1 3 3 2 1 2 1 data_411 + 0 3 3 2 1 2 2 data_412 + 1 3 3 2 1 3 1 data_413 + 0 3 3 2 1 3 2 data_414 + 1 3 3 2 1 4 1 data_415 + 0 3 3 2 1 4 2 data_416 + 1 3 3 2 2 1 1 data_417 + 0 3 3 2 2 1 2 data_418 + 0 3 3 2 2 2 1 data_419 + 0 3 3 2 2 2 2 data_420 + 0 3 3 2 2 3 1 data_421 + 0 3 3 2 2 3 2 data_422 + 0 3 3 2 2 4 1 data_423 + 0 3 3 2 2 4 2 data_424 + 1 3 3 2 3 1 1 data_425 + 0 3 3 2 3 1 2 data_426 + 0 3 3 2 3 2 1 data_427 + 0 3 3 2 3 2 2 data_428 + 0 3 3 2 3 3 1 data_429 + 0 3 3 2 3 3 2 data_430 + 0 3 3 2 3 4 1 data_431 + 0 3 3 2 3 4 2 data_432 diff --git a/extra/machine-learning/data-sets/monks-2.train b/extra/machine-learning/data-sets/monks-2.train new file mode 100644 index 0000000000..ef18038f21 --- /dev/null +++ b/extra/machine-learning/data-sets/monks-2.train @@ -0,0 +1,169 @@ + 0 1 1 1 1 2 2 data_4 + 0 1 1 1 1 4 1 data_7 + 0 1 1 1 2 1 1 data_9 + 0 1 1 1 2 1 2 data_10 + 0 1 1 1 2 2 1 data_11 + 0 1 1 1 2 3 1 data_13 + 0 1 1 1 2 4 1 data_15 + 0 1 1 1 3 2 1 data_19 + 0 1 1 1 3 4 1 data_23 + 0 1 1 2 1 1 1 data_25 + 0 1 1 2 1 1 2 data_26 + 0 1 1 2 2 3 1 data_37 + 0 1 1 2 2 4 1 data_39 + 1 1 1 2 2 4 2 data_40 + 0 1 1 2 3 1 2 data_42 + 1 1 1 2 3 2 2 data_44 + 0 1 2 1 1 1 2 data_50 + 0 1 2 1 2 1 2 data_58 + 1 1 2 1 2 2 2 data_60 + 0 1 2 1 2 3 1 data_61 + 1 1 2 1 2 3 2 data_62 + 0 1 2 1 2 4 1 data_63 + 0 1 2 1 3 1 1 data_65 + 0 1 2 1 3 1 2 data_66 + 1 1 2 1 3 2 2 data_68 + 0 1 2 1 3 3 1 data_69 + 1 1 2 1 3 3 2 data_70 + 0 1 2 1 3 4 1 data_71 + 1 1 2 1 3 4 2 data_72 + 0 1 2 2 1 2 1 data_75 + 0 1 2 2 1 4 1 data_79 + 1 1 2 2 2 3 1 data_85 + 1 1 2 2 2 4 1 data_87 + 0 1 2 2 3 1 1 data_89 + 1 1 2 2 3 1 2 data_90 + 1 1 2 2 3 3 1 data_93 + 0 1 2 2 3 3 2 data_94 + 1 1 2 2 3 4 1 data_95 + 0 1 2 2 3 4 2 data_96 + 0 1 3 1 1 1 2 data_98 + 0 1 3 1 1 2 2 data_100 + 0 1 3 1 1 3 1 data_101 + 0 1 3 1 1 3 2 data_102 + 0 1 3 1 2 2 1 data_107 + 1 1 3 1 2 2 2 data_108 + 1 1 3 1 2 3 2 data_110 + 0 1 3 1 2 4 1 data_111 + 1 1 3 1 3 2 2 data_116 + 0 1 3 1 3 3 1 data_117 + 1 1 3 1 3 4 2 data_120 + 0 1 3 2 1 3 1 data_125 + 1 1 3 2 1 3 2 data_126 + 0 1 3 2 1 4 1 data_127 + 1 1 3 2 2 1 2 data_130 + 0 1 3 2 2 3 2 data_134 + 0 1 3 2 2 4 2 data_136 + 1 1 3 2 3 2 1 data_139 + 0 2 1 1 1 1 1 data_145 + 0 2 1 1 1 2 2 data_148 + 0 2 1 1 1 3 1 data_149 + 1 2 1 1 2 2 2 data_156 + 0 2 1 1 3 1 2 data_162 + 1 2 1 1 3 2 2 data_164 + 1 2 1 1 3 3 2 data_166 + 0 2 1 1 3 4 1 data_167 + 0 2 1 2 1 1 1 data_169 + 1 2 1 2 1 2 2 data_172 + 0 2 1 2 1 4 1 data_175 + 1 2 1 2 2 2 1 data_179 + 0 2 1 2 2 4 2 data_184 + 0 2 1 2 3 1 1 data_185 + 1 2 1 2 3 1 2 data_186 + 0 2 1 2 3 2 2 data_188 + 0 2 1 2 3 3 2 data_190 + 0 2 1 2 3 4 2 data_192 + 0 2 2 1 1 3 1 data_197 + 1 2 2 1 1 4 2 data_200 + 0 2 2 1 2 1 1 data_201 + 1 2 2 1 2 3 1 data_205 + 1 2 2 1 3 3 1 data_213 + 0 2 2 1 3 3 2 data_214 + 1 2 2 1 3 4 1 data_215 + 0 2 2 2 1 1 1 data_217 + 0 2 2 2 1 2 2 data_220 + 0 2 2 2 1 3 2 data_222 + 1 2 2 2 1 4 1 data_223 + 0 2 2 2 1 4 2 data_224 + 1 2 2 2 2 1 1 data_225 + 0 2 2 2 2 2 2 data_228 + 0 2 2 2 2 3 1 data_229 + 1 2 2 2 3 1 1 data_233 + 0 2 2 2 3 2 1 data_235 + 0 2 2 2 3 2 2 data_236 + 0 2 2 2 3 4 2 data_240 + 0 2 3 1 1 1 1 data_241 + 0 2 3 1 1 1 2 data_242 + 1 2 3 1 1 3 2 data_246 + 0 2 3 1 2 1 1 data_249 + 1 2 3 1 2 3 1 data_253 + 0 2 3 1 2 3 2 data_254 + 0 2 3 1 2 4 2 data_256 + 1 2 3 1 3 1 2 data_258 + 1 2 3 1 3 2 1 data_259 + 1 2 3 1 3 4 1 data_263 + 1 2 3 2 1 1 2 data_266 + 1 2 3 2 1 2 1 data_267 + 1 2 3 2 1 3 1 data_269 + 0 2 3 2 1 4 2 data_272 + 1 2 3 2 2 1 1 data_273 + 0 2 3 2 2 2 1 data_275 + 0 2 3 2 2 3 2 data_278 + 0 2 3 2 3 3 1 data_285 + 0 2 3 2 3 3 2 data_286 + 0 2 3 2 3 4 2 data_288 + 0 3 1 1 1 4 1 data_295 + 0 3 1 1 2 1 2 data_298 + 1 3 1 1 2 2 2 data_300 + 1 3 1 1 2 3 2 data_302 + 0 3 1 1 2 4 1 data_303 + 1 3 1 1 2 4 2 data_304 + 0 3 1 1 3 1 1 data_305 + 0 3 1 1 3 1 2 data_306 + 1 3 1 1 3 2 2 data_308 + 1 3 1 1 3 3 2 data_310 + 0 3 1 2 1 1 1 data_313 + 1 3 1 2 1 2 2 data_316 + 0 3 1 2 1 3 1 data_317 + 1 3 1 2 1 3 2 data_318 + 0 3 1 2 1 4 1 data_319 + 1 3 1 2 1 4 2 data_320 + 1 3 1 2 2 2 1 data_323 + 1 3 1 2 3 1 2 data_330 + 1 3 1 2 3 2 1 data_331 + 0 3 1 2 3 2 2 data_332 + 0 3 1 2 3 4 2 data_336 + 0 3 2 1 1 1 2 data_338 + 1 3 2 1 1 2 2 data_340 + 0 3 2 1 1 3 1 data_341 + 1 3 2 1 1 3 2 data_342 + 1 3 2 1 2 1 2 data_346 + 1 3 2 1 2 2 1 data_347 + 0 3 2 1 3 1 1 data_353 + 1 3 2 1 3 2 1 data_355 + 1 3 2 1 3 3 1 data_357 + 0 3 2 1 3 3 2 data_358 + 0 3 2 2 1 1 1 data_361 + 0 3 2 2 1 2 2 data_364 + 1 3 2 2 1 3 1 data_365 + 0 3 2 2 1 3 2 data_366 + 1 3 2 2 2 1 1 data_369 + 0 3 2 2 2 2 1 data_371 + 0 3 2 2 2 2 2 data_372 + 0 3 2 2 2 3 2 data_374 + 1 3 2 2 3 1 1 data_377 + 0 3 2 2 3 3 2 data_382 + 0 3 2 2 3 4 2 data_384 + 0 3 3 1 1 1 1 data_385 + 0 3 3 1 1 2 1 data_387 + 0 3 3 1 1 3 1 data_389 + 1 3 3 1 1 3 2 data_390 + 0 3 3 1 2 3 2 data_398 + 0 3 3 2 1 1 1 data_409 + 1 3 3 2 2 1 1 data_417 + 0 3 3 2 2 2 1 data_419 + 0 3 3 2 2 3 1 data_421 + 0 3 3 2 2 3 2 data_422 + 1 3 3 2 3 1 1 data_425 + 0 3 3 2 3 2 1 data_427 + 0 3 3 2 3 4 2 data_432 diff --git a/extra/machine-learning/data-sets/monks-3.test b/extra/machine-learning/data-sets/monks-3.test new file mode 100644 index 0000000000..bfa44e2a6d --- /dev/null +++ b/extra/machine-learning/data-sets/monks-3.test @@ -0,0 +1,432 @@ + 1 1 1 1 1 1 1 data_1 + 1 1 1 1 1 1 2 data_2 + 1 1 1 1 1 2 1 data_3 + 1 1 1 1 1 2 2 data_4 + 1 1 1 1 1 3 1 data_5 + 1 1 1 1 1 3 2 data_6 + 0 1 1 1 1 4 1 data_7 + 0 1 1 1 1 4 2 data_8 + 1 1 1 1 2 1 1 data_9 + 1 1 1 1 2 1 2 data_10 + 1 1 1 1 2 2 1 data_11 + 1 1 1 1 2 2 2 data_12 + 1 1 1 1 2 3 1 data_13 + 1 1 1 1 2 3 2 data_14 + 0 1 1 1 2 4 1 data_15 + 0 1 1 1 2 4 2 data_16 + 1 1 1 1 3 1 1 data_17 + 1 1 1 1 3 1 2 data_18 + 1 1 1 1 3 2 1 data_19 + 1 1 1 1 3 2 2 data_20 + 1 1 1 1 3 3 1 data_21 + 1 1 1 1 3 3 2 data_22 + 0 1 1 1 3 4 1 data_23 + 0 1 1 1 3 4 2 data_24 + 1 1 1 2 1 1 1 data_25 + 1 1 1 2 1 1 2 data_26 + 1 1 1 2 1 2 1 data_27 + 1 1 1 2 1 2 2 data_28 + 1 1 1 2 1 3 1 data_29 + 1 1 1 2 1 3 2 data_30 + 0 1 1 2 1 4 1 data_31 + 0 1 1 2 1 4 2 data_32 + 1 1 1 2 2 1 1 data_33 + 1 1 1 2 2 1 2 data_34 + 1 1 1 2 2 2 1 data_35 + 1 1 1 2 2 2 2 data_36 + 1 1 1 2 2 3 1 data_37 + 1 1 1 2 2 3 2 data_38 + 0 1 1 2 2 4 1 data_39 + 0 1 1 2 2 4 2 data_40 + 1 1 1 2 3 1 1 data_41 + 1 1 1 2 3 1 2 data_42 + 1 1 1 2 3 2 1 data_43 + 1 1 1 2 3 2 2 data_44 + 1 1 1 2 3 3 1 data_45 + 1 1 1 2 3 3 2 data_46 + 0 1 1 2 3 4 1 data_47 + 0 1 1 2 3 4 2 data_48 + 1 1 2 1 1 1 1 data_49 + 1 1 2 1 1 1 2 data_50 + 1 1 2 1 1 2 1 data_51 + 1 1 2 1 1 2 2 data_52 + 1 1 2 1 1 3 1 data_53 + 1 1 2 1 1 3 2 data_54 + 0 1 2 1 1 4 1 data_55 + 0 1 2 1 1 4 2 data_56 + 1 1 2 1 2 1 1 data_57 + 1 1 2 1 2 1 2 data_58 + 1 1 2 1 2 2 1 data_59 + 1 1 2 1 2 2 2 data_60 + 1 1 2 1 2 3 1 data_61 + 1 1 2 1 2 3 2 data_62 + 0 1 2 1 2 4 1 data_63 + 0 1 2 1 2 4 2 data_64 + 1 1 2 1 3 1 1 data_65 + 1 1 2 1 3 1 2 data_66 + 1 1 2 1 3 2 1 data_67 + 1 1 2 1 3 2 2 data_68 + 1 1 2 1 3 3 1 data_69 + 1 1 2 1 3 3 2 data_70 + 0 1 2 1 3 4 1 data_71 + 0 1 2 1 3 4 2 data_72 + 1 1 2 2 1 1 1 data_73 + 1 1 2 2 1 1 2 data_74 + 1 1 2 2 1 2 1 data_75 + 1 1 2 2 1 2 2 data_76 + 1 1 2 2 1 3 1 data_77 + 1 1 2 2 1 3 2 data_78 + 0 1 2 2 1 4 1 data_79 + 0 1 2 2 1 4 2 data_80 + 1 1 2 2 2 1 1 data_81 + 1 1 2 2 2 1 2 data_82 + 1 1 2 2 2 2 1 data_83 + 1 1 2 2 2 2 2 data_84 + 1 1 2 2 2 3 1 data_85 + 1 1 2 2 2 3 2 data_86 + 0 1 2 2 2 4 1 data_87 + 0 1 2 2 2 4 2 data_88 + 1 1 2 2 3 1 1 data_89 + 1 1 2 2 3 1 2 data_90 + 1 1 2 2 3 2 1 data_91 + 1 1 2 2 3 2 2 data_92 + 1 1 2 2 3 3 1 data_93 + 1 1 2 2 3 3 2 data_94 + 0 1 2 2 3 4 1 data_95 + 0 1 2 2 3 4 2 data_96 + 0 1 3 1 1 1 1 data_97 + 0 1 3 1 1 1 2 data_98 + 0 1 3 1 1 2 1 data_99 + 0 1 3 1 1 2 2 data_100 + 1 1 3 1 1 3 1 data_101 + 1 1 3 1 1 3 2 data_102 + 0 1 3 1 1 4 1 data_103 + 0 1 3 1 1 4 2 data_104 + 0 1 3 1 2 1 1 data_105 + 0 1 3 1 2 1 2 data_106 + 0 1 3 1 2 2 1 data_107 + 0 1 3 1 2 2 2 data_108 + 0 1 3 1 2 3 1 data_109 + 0 1 3 1 2 3 2 data_110 + 0 1 3 1 2 4 1 data_111 + 0 1 3 1 2 4 2 data_112 + 0 1 3 1 3 1 1 data_113 + 0 1 3 1 3 1 2 data_114 + 0 1 3 1 3 2 1 data_115 + 0 1 3 1 3 2 2 data_116 + 0 1 3 1 3 3 1 data_117 + 0 1 3 1 3 3 2 data_118 + 0 1 3 1 3 4 1 data_119 + 0 1 3 1 3 4 2 data_120 + 0 1 3 2 1 1 1 data_121 + 0 1 3 2 1 1 2 data_122 + 0 1 3 2 1 2 1 data_123 + 0 1 3 2 1 2 2 data_124 + 1 1 3 2 1 3 1 data_125 + 1 1 3 2 1 3 2 data_126 + 0 1 3 2 1 4 1 data_127 + 0 1 3 2 1 4 2 data_128 + 0 1 3 2 2 1 1 data_129 + 0 1 3 2 2 1 2 data_130 + 0 1 3 2 2 2 1 data_131 + 0 1 3 2 2 2 2 data_132 + 0 1 3 2 2 3 1 data_133 + 0 1 3 2 2 3 2 data_134 + 0 1 3 2 2 4 1 data_135 + 0 1 3 2 2 4 2 data_136 + 0 1 3 2 3 1 1 data_137 + 0 1 3 2 3 1 2 data_138 + 0 1 3 2 3 2 1 data_139 + 0 1 3 2 3 2 2 data_140 + 0 1 3 2 3 3 1 data_141 + 0 1 3 2 3 3 2 data_142 + 0 1 3 2 3 4 1 data_143 + 0 1 3 2 3 4 2 data_144 + 1 2 1 1 1 1 1 data_145 + 1 2 1 1 1 1 2 data_146 + 1 2 1 1 1 2 1 data_147 + 1 2 1 1 1 2 2 data_148 + 1 2 1 1 1 3 1 data_149 + 1 2 1 1 1 3 2 data_150 + 0 2 1 1 1 4 1 data_151 + 0 2 1 1 1 4 2 data_152 + 1 2 1 1 2 1 1 data_153 + 1 2 1 1 2 1 2 data_154 + 1 2 1 1 2 2 1 data_155 + 1 2 1 1 2 2 2 data_156 + 1 2 1 1 2 3 1 data_157 + 1 2 1 1 2 3 2 data_158 + 0 2 1 1 2 4 1 data_159 + 0 2 1 1 2 4 2 data_160 + 1 2 1 1 3 1 1 data_161 + 1 2 1 1 3 1 2 data_162 + 1 2 1 1 3 2 1 data_163 + 1 2 1 1 3 2 2 data_164 + 1 2 1 1 3 3 1 data_165 + 1 2 1 1 3 3 2 data_166 + 0 2 1 1 3 4 1 data_167 + 0 2 1 1 3 4 2 data_168 + 1 2 1 2 1 1 1 data_169 + 1 2 1 2 1 1 2 data_170 + 1 2 1 2 1 2 1 data_171 + 1 2 1 2 1 2 2 data_172 + 1 2 1 2 1 3 1 data_173 + 1 2 1 2 1 3 2 data_174 + 0 2 1 2 1 4 1 data_175 + 0 2 1 2 1 4 2 data_176 + 1 2 1 2 2 1 1 data_177 + 1 2 1 2 2 1 2 data_178 + 1 2 1 2 2 2 1 data_179 + 1 2 1 2 2 2 2 data_180 + 1 2 1 2 2 3 1 data_181 + 1 2 1 2 2 3 2 data_182 + 0 2 1 2 2 4 1 data_183 + 0 2 1 2 2 4 2 data_184 + 1 2 1 2 3 1 1 data_185 + 1 2 1 2 3 1 2 data_186 + 1 2 1 2 3 2 1 data_187 + 1 2 1 2 3 2 2 data_188 + 1 2 1 2 3 3 1 data_189 + 1 2 1 2 3 3 2 data_190 + 0 2 1 2 3 4 1 data_191 + 0 2 1 2 3 4 2 data_192 + 1 2 2 1 1 1 1 data_193 + 1 2 2 1 1 1 2 data_194 + 1 2 2 1 1 2 1 data_195 + 1 2 2 1 1 2 2 data_196 + 1 2 2 1 1 3 1 data_197 + 1 2 2 1 1 3 2 data_198 + 0 2 2 1 1 4 1 data_199 + 0 2 2 1 1 4 2 data_200 + 1 2 2 1 2 1 1 data_201 + 1 2 2 1 2 1 2 data_202 + 1 2 2 1 2 2 1 data_203 + 1 2 2 1 2 2 2 data_204 + 1 2 2 1 2 3 1 data_205 + 1 2 2 1 2 3 2 data_206 + 0 2 2 1 2 4 1 data_207 + 0 2 2 1 2 4 2 data_208 + 1 2 2 1 3 1 1 data_209 + 1 2 2 1 3 1 2 data_210 + 1 2 2 1 3 2 1 data_211 + 1 2 2 1 3 2 2 data_212 + 1 2 2 1 3 3 1 data_213 + 1 2 2 1 3 3 2 data_214 + 0 2 2 1 3 4 1 data_215 + 0 2 2 1 3 4 2 data_216 + 1 2 2 2 1 1 1 data_217 + 1 2 2 2 1 1 2 data_218 + 1 2 2 2 1 2 1 data_219 + 1 2 2 2 1 2 2 data_220 + 1 2 2 2 1 3 1 data_221 + 1 2 2 2 1 3 2 data_222 + 0 2 2 2 1 4 1 data_223 + 0 2 2 2 1 4 2 data_224 + 1 2 2 2 2 1 1 data_225 + 1 2 2 2 2 1 2 data_226 + 1 2 2 2 2 2 1 data_227 + 1 2 2 2 2 2 2 data_228 + 1 2 2 2 2 3 1 data_229 + 1 2 2 2 2 3 2 data_230 + 0 2 2 2 2 4 1 data_231 + 0 2 2 2 2 4 2 data_232 + 1 2 2 2 3 1 1 data_233 + 1 2 2 2 3 1 2 data_234 + 1 2 2 2 3 2 1 data_235 + 1 2 2 2 3 2 2 data_236 + 1 2 2 2 3 3 1 data_237 + 1 2 2 2 3 3 2 data_238 + 0 2 2 2 3 4 1 data_239 + 0 2 2 2 3 4 2 data_240 + 0 2 3 1 1 1 1 data_241 + 0 2 3 1 1 1 2 data_242 + 0 2 3 1 1 2 1 data_243 + 0 2 3 1 1 2 2 data_244 + 1 2 3 1 1 3 1 data_245 + 1 2 3 1 1 3 2 data_246 + 0 2 3 1 1 4 1 data_247 + 0 2 3 1 1 4 2 data_248 + 0 2 3 1 2 1 1 data_249 + 0 2 3 1 2 1 2 data_250 + 0 2 3 1 2 2 1 data_251 + 0 2 3 1 2 2 2 data_252 + 0 2 3 1 2 3 1 data_253 + 0 2 3 1 2 3 2 data_254 + 0 2 3 1 2 4 1 data_255 + 0 2 3 1 2 4 2 data_256 + 0 2 3 1 3 1 1 data_257 + 0 2 3 1 3 1 2 data_258 + 0 2 3 1 3 2 1 data_259 + 0 2 3 1 3 2 2 data_260 + 0 2 3 1 3 3 1 data_261 + 0 2 3 1 3 3 2 data_262 + 0 2 3 1 3 4 1 data_263 + 0 2 3 1 3 4 2 data_264 + 0 2 3 2 1 1 1 data_265 + 0 2 3 2 1 1 2 data_266 + 0 2 3 2 1 2 1 data_267 + 0 2 3 2 1 2 2 data_268 + 1 2 3 2 1 3 1 data_269 + 1 2 3 2 1 3 2 data_270 + 0 2 3 2 1 4 1 data_271 + 0 2 3 2 1 4 2 data_272 + 0 2 3 2 2 1 1 data_273 + 0 2 3 2 2 1 2 data_274 + 0 2 3 2 2 2 1 data_275 + 0 2 3 2 2 2 2 data_276 + 0 2 3 2 2 3 1 data_277 + 0 2 3 2 2 3 2 data_278 + 0 2 3 2 2 4 1 data_279 + 0 2 3 2 2 4 2 data_280 + 0 2 3 2 3 1 1 data_281 + 0 2 3 2 3 1 2 data_282 + 0 2 3 2 3 2 1 data_283 + 0 2 3 2 3 2 2 data_284 + 0 2 3 2 3 3 1 data_285 + 0 2 3 2 3 3 2 data_286 + 0 2 3 2 3 4 1 data_287 + 0 2 3 2 3 4 2 data_288 + 1 3 1 1 1 1 1 data_289 + 1 3 1 1 1 1 2 data_290 + 1 3 1 1 1 2 1 data_291 + 1 3 1 1 1 2 2 data_292 + 1 3 1 1 1 3 1 data_293 + 1 3 1 1 1 3 2 data_294 + 0 3 1 1 1 4 1 data_295 + 0 3 1 1 1 4 2 data_296 + 1 3 1 1 2 1 1 data_297 + 1 3 1 1 2 1 2 data_298 + 1 3 1 1 2 2 1 data_299 + 1 3 1 1 2 2 2 data_300 + 1 3 1 1 2 3 1 data_301 + 1 3 1 1 2 3 2 data_302 + 0 3 1 1 2 4 1 data_303 + 0 3 1 1 2 4 2 data_304 + 1 3 1 1 3 1 1 data_305 + 1 3 1 1 3 1 2 data_306 + 1 3 1 1 3 2 1 data_307 + 1 3 1 1 3 2 2 data_308 + 1 3 1 1 3 3 1 data_309 + 1 3 1 1 3 3 2 data_310 + 0 3 1 1 3 4 1 data_311 + 0 3 1 1 3 4 2 data_312 + 1 3 1 2 1 1 1 data_313 + 1 3 1 2 1 1 2 data_314 + 1 3 1 2 1 2 1 data_315 + 1 3 1 2 1 2 2 data_316 + 1 3 1 2 1 3 1 data_317 + 1 3 1 2 1 3 2 data_318 + 0 3 1 2 1 4 1 data_319 + 0 3 1 2 1 4 2 data_320 + 1 3 1 2 2 1 1 data_321 + 1 3 1 2 2 1 2 data_322 + 1 3 1 2 2 2 1 data_323 + 1 3 1 2 2 2 2 data_324 + 1 3 1 2 2 3 1 data_325 + 1 3 1 2 2 3 2 data_326 + 0 3 1 2 2 4 1 data_327 + 0 3 1 2 2 4 2 data_328 + 1 3 1 2 3 1 1 data_329 + 1 3 1 2 3 1 2 data_330 + 1 3 1 2 3 2 1 data_331 + 1 3 1 2 3 2 2 data_332 + 1 3 1 2 3 3 1 data_333 + 1 3 1 2 3 3 2 data_334 + 0 3 1 2 3 4 1 data_335 + 0 3 1 2 3 4 2 data_336 + 1 3 2 1 1 1 1 data_337 + 1 3 2 1 1 1 2 data_338 + 1 3 2 1 1 2 1 data_339 + 1 3 2 1 1 2 2 data_340 + 1 3 2 1 1 3 1 data_341 + 1 3 2 1 1 3 2 data_342 + 0 3 2 1 1 4 1 data_343 + 0 3 2 1 1 4 2 data_344 + 1 3 2 1 2 1 1 data_345 + 1 3 2 1 2 1 2 data_346 + 1 3 2 1 2 2 1 data_347 + 1 3 2 1 2 2 2 data_348 + 1 3 2 1 2 3 1 data_349 + 1 3 2 1 2 3 2 data_350 + 0 3 2 1 2 4 1 data_351 + 0 3 2 1 2 4 2 data_352 + 1 3 2 1 3 1 1 data_353 + 1 3 2 1 3 1 2 data_354 + 1 3 2 1 3 2 1 data_355 + 1 3 2 1 3 2 2 data_356 + 1 3 2 1 3 3 1 data_357 + 1 3 2 1 3 3 2 data_358 + 0 3 2 1 3 4 1 data_359 + 0 3 2 1 3 4 2 data_360 + 1 3 2 2 1 1 1 data_361 + 1 3 2 2 1 1 2 data_362 + 1 3 2 2 1 2 1 data_363 + 1 3 2 2 1 2 2 data_364 + 1 3 2 2 1 3 1 data_365 + 1 3 2 2 1 3 2 data_366 + 0 3 2 2 1 4 1 data_367 + 0 3 2 2 1 4 2 data_368 + 1 3 2 2 2 1 1 data_369 + 1 3 2 2 2 1 2 data_370 + 1 3 2 2 2 2 1 data_371 + 1 3 2 2 2 2 2 data_372 + 1 3 2 2 2 3 1 data_373 + 1 3 2 2 2 3 2 data_374 + 0 3 2 2 2 4 1 data_375 + 0 3 2 2 2 4 2 data_376 + 1 3 2 2 3 1 1 data_377 + 1 3 2 2 3 1 2 data_378 + 1 3 2 2 3 2 1 data_379 + 1 3 2 2 3 2 2 data_380 + 1 3 2 2 3 3 1 data_381 + 1 3 2 2 3 3 2 data_382 + 0 3 2 2 3 4 1 data_383 + 0 3 2 2 3 4 2 data_384 + 0 3 3 1 1 1 1 data_385 + 0 3 3 1 1 1 2 data_386 + 0 3 3 1 1 2 1 data_387 + 0 3 3 1 1 2 2 data_388 + 1 3 3 1 1 3 1 data_389 + 1 3 3 1 1 3 2 data_390 + 0 3 3 1 1 4 1 data_391 + 0 3 3 1 1 4 2 data_392 + 0 3 3 1 2 1 1 data_393 + 0 3 3 1 2 1 2 data_394 + 0 3 3 1 2 2 1 data_395 + 0 3 3 1 2 2 2 data_396 + 0 3 3 1 2 3 1 data_397 + 0 3 3 1 2 3 2 data_398 + 0 3 3 1 2 4 1 data_399 + 0 3 3 1 2 4 2 data_400 + 0 3 3 1 3 1 1 data_401 + 0 3 3 1 3 1 2 data_402 + 0 3 3 1 3 2 1 data_403 + 0 3 3 1 3 2 2 data_404 + 0 3 3 1 3 3 1 data_405 + 0 3 3 1 3 3 2 data_406 + 0 3 3 1 3 4 1 data_407 + 0 3 3 1 3 4 2 data_408 + 0 3 3 2 1 1 1 data_409 + 0 3 3 2 1 1 2 data_410 + 0 3 3 2 1 2 1 data_411 + 0 3 3 2 1 2 2 data_412 + 1 3 3 2 1 3 1 data_413 + 1 3 3 2 1 3 2 data_414 + 0 3 3 2 1 4 1 data_415 + 0 3 3 2 1 4 2 data_416 + 0 3 3 2 2 1 1 data_417 + 0 3 3 2 2 1 2 data_418 + 0 3 3 2 2 2 1 data_419 + 0 3 3 2 2 2 2 data_420 + 0 3 3 2 2 3 1 data_421 + 0 3 3 2 2 3 2 data_422 + 0 3 3 2 2 4 1 data_423 + 0 3 3 2 2 4 2 data_424 + 0 3 3 2 3 1 1 data_425 + 0 3 3 2 3 1 2 data_426 + 0 3 3 2 3 2 1 data_427 + 0 3 3 2 3 2 2 data_428 + 0 3 3 2 3 3 1 data_429 + 0 3 3 2 3 3 2 data_430 + 0 3 3 2 3 4 1 data_431 + 0 3 3 2 3 4 2 data_432 diff --git a/extra/machine-learning/data-sets/monks-3.train b/extra/machine-learning/data-sets/monks-3.train new file mode 100644 index 0000000000..c4569a805f --- /dev/null +++ b/extra/machine-learning/data-sets/monks-3.train @@ -0,0 +1,122 @@ + 1 1 1 1 1 1 2 data_2 + 1 1 1 1 1 2 1 data_3 + 1 1 1 1 1 2 2 data_4 + 0 1 1 1 1 3 1 data_5 + 0 1 1 1 1 4 1 data_7 + 1 1 1 1 2 1 1 data_9 + 1 1 1 1 2 2 2 data_12 + 0 1 1 1 2 4 2 data_16 + 1 1 1 2 1 2 2 data_28 + 0 1 1 2 1 4 2 data_32 + 1 1 1 2 2 2 2 data_36 + 0 1 1 2 2 4 1 data_39 + 0 1 1 2 2 4 2 data_40 + 1 1 1 2 3 1 1 data_41 + 1 1 1 2 3 1 2 data_42 + 1 1 1 2 3 3 1 data_45 + 1 1 1 2 3 3 2 data_46 + 1 1 2 1 1 3 1 data_53 + 1 1 2 1 2 2 1 data_59 + 1 1 2 1 2 2 2 data_60 + 0 1 2 1 2 3 1 data_61 + 1 1 2 1 3 1 1 data_65 + 1 1 2 1 3 1 2 data_66 + 1 1 2 1 3 2 1 data_67 + 1 1 2 1 3 2 2 data_68 + 1 1 2 1 3 3 2 data_70 + 0 1 2 1 3 4 1 data_71 + 1 1 2 2 1 3 1 data_77 + 0 1 2 2 1 4 2 data_80 + 1 1 2 2 2 1 1 data_81 + 1 1 2 2 2 2 1 data_83 + 1 1 2 2 2 2 2 data_84 + 1 1 2 2 3 1 1 data_89 + 1 1 2 2 3 2 1 data_91 + 1 1 2 2 3 2 2 data_92 + 0 1 3 1 1 2 1 data_99 + 0 1 3 1 1 4 1 data_103 + 0 1 3 1 2 3 2 data_110 + 0 1 3 1 2 4 1 data_111 + 0 1 3 1 3 1 1 data_113 + 0 1 3 1 3 3 1 data_117 + 0 1 3 2 1 1 1 data_121 + 0 1 3 2 1 1 2 data_122 + 0 1 3 2 1 2 1 data_123 + 0 1 3 2 1 4 2 data_128 + 0 1 3 2 2 3 2 data_134 + 0 1 3 2 2 4 2 data_136 + 0 1 3 2 3 4 1 data_143 + 1 2 1 1 1 1 1 data_145 + 1 2 1 1 1 1 2 data_146 + 0 2 1 1 1 4 1 data_151 + 0 2 1 1 1 4 2 data_152 + 1 2 1 1 2 1 1 data_153 + 1 2 1 1 2 1 2 data_154 + 1 2 1 1 3 2 2 data_164 + 1 2 1 1 3 3 2 data_166 + 0 2 1 1 3 4 1 data_167 + 1 2 1 2 1 2 2 data_172 + 0 2 1 2 2 4 1 data_183 + 1 2 1 2 3 1 2 data_186 + 1 2 2 1 1 3 2 data_198 + 0 2 2 1 1 4 2 data_200 + 1 2 2 1 2 1 2 data_202 + 0 2 2 1 2 2 1 data_203 + 1 2 2 1 3 1 1 data_209 + 1 2 2 1 3 2 2 data_212 + 0 2 2 1 3 3 1 data_213 + 0 2 2 1 3 3 2 data_214 + 0 2 2 1 3 4 2 data_216 + 1 2 2 2 1 2 2 data_220 + 1 2 2 2 2 1 2 data_226 + 1 2 2 2 2 3 1 data_229 + 1 2 2 2 2 3 2 data_230 + 0 2 2 2 3 4 1 data_239 + 1 2 3 1 1 3 1 data_245 + 0 2 3 1 2 1 1 data_249 + 0 2 3 1 2 2 1 data_251 + 0 2 3 1 2 2 2 data_252 + 0 2 3 1 2 3 2 data_254 + 0 2 3 1 3 3 1 data_261 + 0 2 3 2 1 1 2 data_266 + 0 2 3 2 1 2 2 data_268 + 0 2 3 2 1 4 1 data_271 + 0 2 3 2 2 3 1 data_277 + 0 2 3 2 2 4 2 data_280 + 0 2 3 2 3 1 1 data_281 + 0 2 3 2 3 2 1 data_283 + 0 2 3 2 3 4 2 data_288 + 1 3 1 1 1 1 1 data_289 + 1 3 1 1 1 2 1 data_291 + 1 3 1 1 1 3 1 data_293 + 0 3 1 1 2 4 2 data_304 + 1 3 1 1 3 1 2 data_306 + 0 3 1 1 3 4 2 data_312 + 1 3 1 2 1 2 1 data_315 + 1 3 1 2 2 3 2 data_326 + 0 3 1 2 2 4 2 data_328 + 1 3 1 2 3 1 1 data_329 + 1 3 2 1 1 2 2 data_340 + 0 3 2 1 1 4 1 data_343 + 1 3 2 1 2 3 1 data_349 + 1 3 2 1 3 1 2 data_354 + 1 3 2 2 1 2 2 data_364 + 1 3 2 2 1 3 2 data_366 + 1 3 2 2 2 1 2 data_370 + 1 3 2 2 3 1 1 data_377 + 1 3 2 2 3 3 2 data_382 + 0 3 2 2 3 4 1 data_383 + 1 3 3 1 1 3 2 data_390 + 1 3 3 1 1 4 1 data_391 + 0 3 3 1 2 4 2 data_400 + 0 3 3 1 3 1 1 data_401 + 0 3 3 1 3 2 1 data_403 + 0 3 3 1 3 2 2 data_404 + 0 3 3 1 3 4 1 data_407 + 0 3 3 2 1 1 1 data_409 + 0 3 3 2 1 1 2 data_410 + 0 3 3 2 2 2 2 data_420 + 0 3 3 2 2 3 2 data_422 + 0 3 3 2 3 1 1 data_425 + 0 3 3 2 3 3 2 data_430 + 0 3 3 2 3 4 2 data_432 diff --git a/extra/machine-learning/data-sets/monks.names b/extra/machine-learning/data-sets/monks.names new file mode 100644 index 0000000000..caada35d0b --- /dev/null +++ b/extra/machine-learning/data-sets/monks.names @@ -0,0 +1,76 @@ +1. Title: The Monk's Problems + +2. Sources: + (a) Donor: Sebastian Thrun + School of Computer Science + Carnegie Mellon University + Pittsburgh, PA 15213, USA + + E-mail: thrun@cs.cmu.edu + + (b) Date: October 1992 + +3. Past Usage: + + - See File: thrun.comparison.ps.Z + + - Wnek, J., "Hypothesis-driven Constructive Induction," PhD dissertation, + School of Information Technology and Engineering, Reports of Machine + Learning and Inference Laboratory, MLI 93-2, Center for Artificial + Intelligence, George Mason University, March 1993. + + - Wnek, J. and Michalski, R.S., "Comparing Symbolic and + Subsymbolic Learning: Three Studies," in Machine Learning: A + Multistrategy Approach, Vol. 4., R.S. Michalski and G. Tecuci (Eds.), + Morgan Kaufmann, San Mateo, CA, 1993. + +4. Relevant Information: + + The MONK's problem were the basis of a first international comparison + of learning algorithms. The result of this comparison is summarized in + "The MONK's Problems - A Performance Comparison of Different Learning + algorithms" by S.B. Thrun, J. Bala, E. Bloedorn, I. Bratko, B. + Cestnik, J. Cheng, K. De Jong, S. Dzeroski, S.E. Fahlman, D. Fisher, + R. Hamann, K. Kaufman, S. Keller, I. Kononenko, J. Kreuziger, R.S. + Michalski, T. Mitchell, P. Pachowicz, Y. Reich H. Vafaie, W. Van de + Welde, W. Wenzel, J. Wnek, and J. Zhang has been published as + Technical Report CS-CMU-91-197, Carnegie Mellon University in Dec. + 1991. + + One significant characteristic of this comparison is that it was + performed by a collection of researchers, each of whom was an advocate + of the technique they tested (often they were the creators of the + various methods). In this sense, the results are less biased than in + comparisons performed by a single person advocating a specific + learning method, and more accurately reflect the generalization + behavior of the learning techniques as applied by knowledgeable users. + + There are three MONK's problems. The domains for all MONK's problems + are the same (described below). One of the MONK's problems has noise + added. For each problem, the domain has been partitioned into a train + and test set. + +5. Number of Instances: 432 + +6. Number of Attributes: 8 (including class attribute) + +7. Attribute information: + 1. class: 0, 1 + 2. a1: 1, 2, 3 + 3. a2: 1, 2, 3 + 4. a3: 1, 2 + 5. a4: 1, 2, 3 + 6. a5: 1, 2, 3, 4 + 7. a6: 1, 2 + 8. Id: (A unique symbol for each instance) + +8. Missing Attribute Values: None + +9. Target Concepts associated to the MONK's problem: + + MONK-1: (a1 = a2) or (a5 = 1) + + MONK-2: EXACTLY TWO of {a1 = 1, a2 = 1, a3 = 1, a4 = 1, a5 = 1, a6 = 1} + + MONK-3: (a5 = 3 and a4 = 1) or (a5 /= 4 and a2 /= 3) + (5% class noise added to the training set) diff --git a/extra/machine-learning/decision-trees/decision-trees-tests.factor b/extra/machine-learning/decision-trees/decision-trees-tests.factor new file mode 100644 index 0000000000..31d2d24970 --- /dev/null +++ b/extra/machine-learning/decision-trees/decision-trees-tests.factor @@ -0,0 +1,16 @@ +! Copyright (C) 2018 Björn Lindqvist +! See http://factorcode.org/license.txt for BSD license +USING: kernel machine-learning.data-sets +machine-learning.decision-trees math.extras sequences tools.test ; +IN: machine-learning.decision-trees.tests + +{ { 0.08 0.01 0.0 0.03 0.29 0.0 } } [ + "monks-1.train" load-monks + 6 [ + average-gain 2 round-to-decimal + ] with map +] unit-test + +{ 4 } [ + "monks-1.train" load-monks highest-gain-index +] unit-test diff --git a/extra/machine-learning/decision-trees/decision-trees.factor b/extra/machine-learning/decision-trees/decision-trees.factor new file mode 100644 index 0000000000..b843e7847f --- /dev/null +++ b/extra/machine-learning/decision-trees/decision-trees.factor @@ -0,0 +1,33 @@ +! Copyright (C) 2018 Björn Lindqvist +! See http://factorcode.org/license.txt for BSD license +USING: accessors assocs fry grouping.extras kernel locals math +math.functions math.statistics sequences sequences.extras sorting ; +IN: machine-learning.decision-trees + +! Why convert the logarithm to base 2? I don't know. +: entropy2 ( seq -- e ) + normalized-histogram values entropy 2 log / ; + +: group-by-sorted ( seq quot: ( elt -- key ) -- groups ) + [ sort-with ] keep group-by ; inline + +: subsets-weighted-entropy ( data-target idx -- seq ) + ! Group the data according to the given index. + '[ first _ swap nth ] group-by-sorted + ! Then unpack the partitioned groups of targets + '[ [ second ] map ] assoc-map values + ! Finally, calculate the weighted entropy for each group + [ [ entropy2 ] [ length ] bi * ] map-sum ; inline + +:: average-gain ( dataset idx -- gain ) + dataset target>> :> target + dataset data>> :> data + data target zip :> data-target + data-target idx subsets-weighted-entropy :> weighted + + target entropy2 weighted data length / - ; + +: highest-gain-index ( dataset -- idx ) + dup feature-names>> length [ + average-gain + ] with map arg-max ; diff --git a/extra/math/splines/viewer/viewer.factor b/extra/math/splines/viewer/viewer.factor index 59c347d740..1084510f2b 100644 --- a/extra/math/splines/viewer/viewer.factor +++ b/extra/math/splines/viewer/viewer.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel locals math math.order math.polynomials -math.splines opengl.gl sequences ui.gadgets ui.gadgets.panes ui.render -arrays ; +math.splines opengl.demo-support opengl.gl sequences ui.gadgets +ui.gadgets.panes ui.render arrays ; IN: math.splines.viewer > second * ] bi 2array ] map :> pts - GL_LINE_STRIP glBegin - pts [ - first2 neg gadget spline-dim>> second + glVertex2f - ] each - glEnd ; + GL_LINE_STRIP [ + pts [ + first2 neg gadget spline-dim>> second + glVertex2f + ] each ] + do-state ; :: ( polynomials dim steps -- gadget ) spline-gadget new diff --git a/extra/maze/maze.factor b/extra/maze/maze.factor index 0e4af964d3..f682d4600d 100644 --- a/extra/maze/maze.factor +++ b/extra/maze/maze.factor @@ -1,7 +1,7 @@ ! From http://www.ffconsultancy.com/ocaml/maze/index.html USING: accessors arrays fry kernel math math.order math.vectors -namespaces opengl.gl random sequences ui ui.gadgets -ui.gadgets.canvas ui.render ; +namespaces opengl.demo-support opengl.gl random sequences ui +ui.gadgets ui.gadgets.canvas ui.render ; IN: maze CONSTANT: line-width 8 @@ -25,7 +25,7 @@ SYMBOL: visited : (draw-maze) ( cell -- ) dup vertex glEnd - GL_POINTS glBegin dup vertex glEnd + GL_POINTS [ dup vertex ] do-state GL_LINE_STRIP glBegin dup vertex dup visit @@ -42,9 +42,9 @@ SYMBOL: visited line-width 2 - glPointSize 1.0 1.0 1.0 1.0 glColor4d dup '[ _ t ] replicate visited set - GL_LINE_STRIP glBegin - { 0 0 } dup vertex (draw-maze) - glEnd ; + GL_LINE_STRIP [ + { 0 0 } dup vertex (draw-maze) + ] do-state ; TUPLE: maze < canvas ; diff --git a/extra/minesweeper/_resources/blank.gif b/extra/minesweeper/_resources/blank.gif new file mode 100644 index 0000000000..5c50d90375 Binary files /dev/null and b/extra/minesweeper/_resources/blank.gif differ diff --git a/extra/minesweeper/_resources/digit-.gif b/extra/minesweeper/_resources/digit-.gif new file mode 100644 index 0000000000..025cd8a53a Binary files /dev/null and b/extra/minesweeper/_resources/digit-.gif differ diff --git a/extra/minesweeper/_resources/digit0.gif b/extra/minesweeper/_resources/digit0.gif new file mode 100644 index 0000000000..304bc14148 Binary files /dev/null and b/extra/minesweeper/_resources/digit0.gif differ diff --git a/extra/minesweeper/_resources/digit1.gif b/extra/minesweeper/_resources/digit1.gif new file mode 100644 index 0000000000..fdbdb9f64c Binary files /dev/null and b/extra/minesweeper/_resources/digit1.gif differ diff --git a/extra/minesweeper/_resources/digit2.gif b/extra/minesweeper/_resources/digit2.gif new file mode 100644 index 0000000000..f3e1b89057 Binary files /dev/null and b/extra/minesweeper/_resources/digit2.gif differ diff --git a/extra/minesweeper/_resources/digit3.gif b/extra/minesweeper/_resources/digit3.gif new file mode 100644 index 0000000000..5a79680320 Binary files /dev/null and b/extra/minesweeper/_resources/digit3.gif differ diff --git a/extra/minesweeper/_resources/digit4.gif b/extra/minesweeper/_resources/digit4.gif new file mode 100644 index 0000000000..d379d63ccc Binary files /dev/null and b/extra/minesweeper/_resources/digit4.gif differ diff --git a/extra/minesweeper/_resources/digit5.gif b/extra/minesweeper/_resources/digit5.gif new file mode 100644 index 0000000000..589a1a1409 Binary files /dev/null and b/extra/minesweeper/_resources/digit5.gif differ diff --git a/extra/minesweeper/_resources/digit6.gif b/extra/minesweeper/_resources/digit6.gif new file mode 100644 index 0000000000..232f606e94 Binary files /dev/null and b/extra/minesweeper/_resources/digit6.gif differ diff --git a/extra/minesweeper/_resources/digit7.gif b/extra/minesweeper/_resources/digit7.gif new file mode 100644 index 0000000000..56ab859b58 Binary files /dev/null and b/extra/minesweeper/_resources/digit7.gif differ diff --git a/extra/minesweeper/_resources/digit8.gif b/extra/minesweeper/_resources/digit8.gif new file mode 100644 index 0000000000..aca981ffed Binary files /dev/null and b/extra/minesweeper/_resources/digit8.gif differ diff --git a/extra/minesweeper/_resources/digit9.gif b/extra/minesweeper/_resources/digit9.gif new file mode 100644 index 0000000000..f4ee44ef04 Binary files /dev/null and b/extra/minesweeper/_resources/digit9.gif differ diff --git a/extra/minesweeper/_resources/flagged.gif b/extra/minesweeper/_resources/flagged.gif new file mode 100644 index 0000000000..46dc1b21b9 Binary files /dev/null and b/extra/minesweeper/_resources/flagged.gif differ diff --git a/extra/minesweeper/_resources/mine.gif b/extra/minesweeper/_resources/mine.gif new file mode 100644 index 0000000000..f7b12c27e4 Binary files /dev/null and b/extra/minesweeper/_resources/mine.gif differ diff --git a/extra/minesweeper/_resources/mineclicked.gif b/extra/minesweeper/_resources/mineclicked.gif new file mode 100644 index 0000000000..f7416c9cd2 Binary files /dev/null and b/extra/minesweeper/_resources/mineclicked.gif differ diff --git a/extra/minesweeper/_resources/misflagged.gif b/extra/minesweeper/_resources/misflagged.gif new file mode 100644 index 0000000000..cbbb32c0f2 Binary files /dev/null and b/extra/minesweeper/_resources/misflagged.gif differ diff --git a/extra/minesweeper/_resources/open0.gif b/extra/minesweeper/_resources/open0.gif new file mode 100644 index 0000000000..1ae6d3a4d6 Binary files /dev/null and b/extra/minesweeper/_resources/open0.gif differ diff --git a/extra/minesweeper/_resources/open1.gif b/extra/minesweeper/_resources/open1.gif new file mode 100644 index 0000000000..4c6b2bd9ad Binary files /dev/null and b/extra/minesweeper/_resources/open1.gif differ diff --git a/extra/minesweeper/_resources/open2.gif b/extra/minesweeper/_resources/open2.gif new file mode 100644 index 0000000000..465aa36d6b Binary files /dev/null and b/extra/minesweeper/_resources/open2.gif differ diff --git a/extra/minesweeper/_resources/open3.gif b/extra/minesweeper/_resources/open3.gif new file mode 100644 index 0000000000..58d96b5583 Binary files /dev/null and b/extra/minesweeper/_resources/open3.gif differ diff --git a/extra/minesweeper/_resources/open4.gif b/extra/minesweeper/_resources/open4.gif new file mode 100644 index 0000000000..ae123dcd1b Binary files /dev/null and b/extra/minesweeper/_resources/open4.gif differ diff --git a/extra/minesweeper/_resources/open5.gif b/extra/minesweeper/_resources/open5.gif new file mode 100644 index 0000000000..e93896718c Binary files /dev/null and b/extra/minesweeper/_resources/open5.gif differ diff --git a/extra/minesweeper/_resources/open6.gif b/extra/minesweeper/_resources/open6.gif new file mode 100644 index 0000000000..8f79b0dcf5 Binary files /dev/null and b/extra/minesweeper/_resources/open6.gif differ diff --git a/extra/minesweeper/_resources/open7.gif b/extra/minesweeper/_resources/open7.gif new file mode 100644 index 0000000000..5618e641a9 Binary files /dev/null and b/extra/minesweeper/_resources/open7.gif differ diff --git a/extra/minesweeper/_resources/open8.gif b/extra/minesweeper/_resources/open8.gif new file mode 100644 index 0000000000..59c777f00f Binary files /dev/null and b/extra/minesweeper/_resources/open8.gif differ diff --git a/extra/minesweeper/_resources/question.gif b/extra/minesweeper/_resources/question.gif new file mode 100644 index 0000000000..ccc79bbef2 Binary files /dev/null and b/extra/minesweeper/_resources/question.gif differ diff --git a/extra/minesweeper/_resources/smiley.gif b/extra/minesweeper/_resources/smiley.gif new file mode 100644 index 0000000000..11b8045e88 Binary files /dev/null and b/extra/minesweeper/_resources/smiley.gif differ diff --git a/extra/minesweeper/_resources/smileylost.gif b/extra/minesweeper/_resources/smileylost.gif new file mode 100644 index 0000000000..53ecfae8c5 Binary files /dev/null and b/extra/minesweeper/_resources/smileylost.gif differ diff --git a/extra/minesweeper/_resources/smileyuhoh.gif b/extra/minesweeper/_resources/smileyuhoh.gif new file mode 100644 index 0000000000..06ab22615b Binary files /dev/null and b/extra/minesweeper/_resources/smileyuhoh.gif differ diff --git a/extra/minesweeper/_resources/smileywon.gif b/extra/minesweeper/_resources/smileywon.gif new file mode 100644 index 0000000000..738575d3fc Binary files /dev/null and b/extra/minesweeper/_resources/smileywon.gif differ diff --git a/extra/minesweeper/authors.txt b/extra/minesweeper/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/minesweeper/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/minesweeper/minesweeper.factor b/extra/minesweeper/minesweeper.factor new file mode 100644 index 0000000000..c44df91f1b --- /dev/null +++ b/extra/minesweeper/minesweeper.factor @@ -0,0 +1,299 @@ +! Copyright (C) 2017 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: accessors arrays assocs calendar colors.constants +combinators combinators.short-circuit destructors formatting fry +images.loader kernel locals math math.order math.parser +namespaces opengl opengl.textures random sequences timers ui +ui.commands ui.gadgets ui.gadgets.toolbar ui.gadgets.tracks +ui.gadgets.worlds ui.gestures ui.pens.solid ui.render words ; + +IN: minesweeper + +CONSTANT: neighbors { + { -1 -1 } { -1 0 } { -1 1 } + { 0 -1 } { 0 1 } + { 1 -1 } { 1 0 } { 1 1 } +} + +SYMBOLS: +flagged+ +question+ +clicked+ ; + +TUPLE: cell #adjacent mined? state ; + +: make-cells ( rows cols -- cells ) + '[ _ [ cell new ] replicate ] replicate ; + +:: cell-at ( cells row col -- cell/f ) + row cells ?nth [ col swap ?nth ] [ f ] if* ; + +: cells-dim ( cells -- rows cols ) + [ length ] [ first length ] bi ; + +: unmined-cell ( cells -- cell ) + f [ dup mined?>> ] [ drop dup random random ] do while nip ; + +: #mines ( cells -- n ) + [ [ mined?>> ] count ] map-sum ; + +: #flagged ( cells -- n ) + [ [ state>> +flagged+ = ] count ] map-sum ; + +: #mines-remaining ( cells -- n ) + [ #mines ] [ #flagged ] bi - ; + +: place-mines ( cells n -- cells ) + [ dup unmined-cell t >>mined? drop ] times ; + +: adjacent-mines ( cells row col -- #mines ) + neighbors [ + first2 [ + ] bi-curry@ bi* cell-at + [ mined?>> ] [ f ] if* + ] with with with count ; + +:: each-cell ( ... cells quot: ( ... row col cell -- ... ) -- ... ) + cells [| row | + [| cell col | row col cell quot call ] each-index + ] each-index ; inline + +:: update-counts ( cells -- cells ) + cells [| row col cell | + cells row col adjacent-mines cell #adjacent<< + ] each-cell cells ; + +: reset-cells ( cells -- cells ) + [ cells-dim make-cells ] [ #mines place-mines ] bi update-counts ; + +: won? ( cells -- ? ) + [ [ { [ state>> +clicked+ = ] [ mined?>> ] } 1|| ] all? ] all? ; + +: lost? ( cells -- ? ) + [ [ { [ state>> +clicked+ = ] [ mined?>> ] } 1&& ] any? ] any? ; + +: game-over? ( cells -- ? ) + { [ lost? ] [ won? ] } 1|| ; + +: new-game? ( cells -- ? ) + [ [ state>> +clicked+ = ] any? ] any? not ; + +DEFER: click-cell-at + +:: click-cells-around ( cells row col -- ) + neighbors [ + first2 [ row + ] [ col + ] bi* :> ( row' col' ) + cells row' col' cell-at [ + { [ mined?>> ] [ state>> +question+ = ] } 1|| [ + cells row' col' click-cell-at drop + ] unless + ] when* + ] each ; + +:: click-cell-at ( cells row col -- ? ) + cells row col cell-at [ + cells new-game? [ + ! first click shouldn't be a mine + dup mined?>> [ + cells unmined-cell t >>mined? drop f >>mined? + cells update-counts drop + ] when + ] when + dup state>> { +clicked+ +flagged+ } member? [ drop f ] [ + +clicked+ >>state + { [ mined?>> not ] [ #adjacent>> 0 = ] } 1&& [ + cells row col click-cells-around + ] when t + ] if + ] [ f ] if* ; + +:: mark-cell-at ( cells row col -- ? ) + cells row col cell-at [ + dup state>> { + { +clicked+ [ +clicked+ ] } + { +flagged+ [ +question+ ] } + { +question+ [ f ] } + { f [ +flagged+ ] } + } case >>state drop t + ] [ f ] if* ; + +TUPLE: grid-gadget < gadget cells timer textures start end ; + +:: ( rows cols mines -- gadget ) + grid-gadget new + rows cols make-cells + mines place-mines update-counts >>cells + H{ } clone >>textures + dup '[ _ relayout-1 ] f 1 seconds >>timer + COLOR: gray >>interior ; + +M: grid-gadget graft* + [ timer>> start-timer ] [ call-next-method ] bi ; + +M: grid-gadget ungraft* + [ + dup find-gl-context + [ values dispose-each H{ } clone ] change-textures + timer>> stop-timer + ] [ call-next-method ] bi ; + +M: grid-gadget pref-dim* + cells>> cells-dim [ 32 * ] bi@ swap 58 + 2array ; + +:: cell-image-path ( cell game-over? -- image-path ) + game-over? cell mined?>> and [ + cell state>> +clicked+ = "mineclicked.gif" "mine.gif" ? + ] [ + cell state>> + { + { +question+ [ "question.gif" ] } + { +flagged+ [ game-over? "misflagged.gif" "flagged.gif" ? ] } + { +clicked+ [ + cell mined?>> [ + "mine.gif" + ] [ + cell #adjacent>> 0 or number>string + "open" ".gif" surround + ] if ] } + { f [ "blank.gif" ] } + } case + ] if "vocab:minesweeper/_resources/" prepend ; + +: digit-image-path ( ch -- image-path ) + "vocab:minesweeper/_resources/digit%c.gif" sprintf ; + +:: smiley-image-path ( won? lost? clicking? -- image-path ) + { + { [ lost? ] [ "vocab:minesweeper/_resources/smileylost.gif" ] } + { [ won? ] [ "vocab:minesweeper/_resources/smileywon.gif" ] } + { [ clicking? ] [ "vocab:minesweeper/_resources/smileyuhoh.gif" ] } + [ "vocab:minesweeper/_resources/smiley.gif" ] + } cond ; + +: cached-texture ( path gadget -- texture ) + textures>> [ load-image { 0 0 } ] cache ; + +:: draw-mines ( n gadget -- ) + n "%03d" sprintf [ + 26 * 3 + 6 2array [ + digit-image-path gadget cached-texture + { 26 46 } swap draw-scaled-texture + ] with-translation + ] each-index ; + +:: draw-smiley ( gadget -- ) + gadget pref-dim first :> width + width 2/ 26 - 3 2array [ + gadget cells>> won? + gadget cells>> lost? + hand-buttons get-global empty? not + gadget hand-click-rel second 58 >= and + smiley-image-path + gadget cached-texture { 52 52 } swap draw-scaled-texture + ] with-translation ; + +:: draw-timer ( n gadget -- ) + gadget pref-dim first :> width + n "%03d" sprintf [ + 3 swap - 26 * width swap - 3 - 6 2array [ + digit-image-path gadget cached-texture + { 26 46 } swap draw-scaled-texture + ] with-translation + ] each-index ; + +:: draw-cells ( gadget -- ) + gadget cells>> game-over? :> game-over? + gadget cells>> [| row col cell | + col row [ 32 * ] bi@ 58 + 2array [ + cell game-over? cell-image-path + gadget cached-texture + { 32 32 } swap draw-scaled-texture + ] with-translation + ] each-cell ; + +:: elapsed-time ( gadget -- n ) + gadget start>> [ + gadget end>> now or swap time- duration>seconds + ] [ 0 ] if* ; + +M: grid-gadget draw-gadget* + { + [ cells>> #mines-remaining ] + [ draw-mines ] + [ draw-smiley ] + [ elapsed-time ] + [ draw-timer ] + [ draw-cells ] + } cleave ; + +:: on-click ( gadget -- ) + gadget hand-rel first2 :> ( w h ) + h 58 < [ + h 3 55 between? + gadget pref-dim first 2/ w - abs 26 < and [ + gadget [ reset-cells ] change-cells + f >>start f >>end relayout-1 + ] when + ] [ + h 58 - w [ 32 /i ] bi@ :> ( row col ) + gadget cells>> :> cells + cells game-over? [ + cells row col click-cell-at [ + gadget start>> [ now gadget start<< ] unless + cells game-over? [ now gadget end<< ] when + gadget relayout-1 + ] when + ] unless + ] if ; + +:: on-mark ( gadget -- ) + gadget hand-rel first2 :> ( w h ) + h 58 >= [ + h 58 - w [ 32 /i ] bi@ :> ( row col ) + gadget cells>> :> cells + cells game-over? [ + cells row col mark-cell-at [ + gadget start>> [ now gadget start<< ] unless + cells game-over? [ now gadget end<< ] when + gadget relayout-1 + ] when + ] unless + ] when ; + +: new-game ( gadget rows cols mines -- ) + [ make-cells ] dip place-mines update-counts >>cells + f >>start f >>end relayout-window ; + +: com-easy ( gadget -- ) 7 7 10 new-game ; + +: com-medium ( gadget -- ) 15 15 40 new-game ; + +: com-hard ( gadget -- ) 15 30 99 new-game ; + +grid-gadget "toolbar" f { + { T{ key-down { sym "1" } } com-easy } + { T{ key-down { sym "2" } } com-medium } + { T{ key-down { sym "3" } } com-hard } +} define-command-map + +grid-gadget "gestures" [ + { + { T{ button-down { # 1 } } [ relayout-1 ] } + { T{ button-up { # 1 } } [ on-click ] } + { T{ button-up { # 3 } } [ on-mark ] } + { T{ key-down { sym " " } } [ on-mark ] } + } assoc-union +] change-word-prop + +TUPLE: minesweeper-gadget < track ; + +: ( -- gadget ) + vertical minesweeper-gadget new-track + 7 7 10 + [ format-toolbar f track-add ] + [ 1 track-add ] bi ; + +M: minesweeper-gadget focusable-child* children>> second ; + +MAIN-WINDOW: run-minesweeper { + { title "Minesweeper" } + { window-controls + { normal-title-bar close-button minimize-button } } + } >>gadgets ; diff --git a/extra/minesweeper/resources.txt b/extra/minesweeper/resources.txt new file mode 100644 index 0000000000..fcacd6e132 --- /dev/null +++ b/extra/minesweeper/resources.txt @@ -0,0 +1 @@ +_resources diff --git a/extra/minesweeper/summary.txt b/extra/minesweeper/summary.txt new file mode 100644 index 0000000000..a790673721 --- /dev/null +++ b/extra/minesweeper/summary.txt @@ -0,0 +1 @@ +Minesweeper game diff --git a/extra/minesweeper/tags.txt b/extra/minesweeper/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/minesweeper/tags.txt @@ -0,0 +1 @@ +demos diff --git a/extra/oauth2/oauth2-docs.factor b/extra/oauth2/oauth2-docs.factor new file mode 100644 index 0000000000..2f87cbc088 --- /dev/null +++ b/extra/oauth2/oauth2-docs.factor @@ -0,0 +1,24 @@ +! Copyright (C) 2018 Björn Lindqvist. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax ; +IN: oauth2 + +ARTICLE: "oauth2" "Oauth2 Support" +"The " { $vocab-link "oauth2" } " vocab implements client support for the Oauth2 protocol." +$nl +"To use the oauth2 vocab, first create an instance of the " { $link oauth2 } " class to represent the Oauth2 provider's settings. The slots 'auth-uri' and 'token-uri' should be set to the providers authentication and token uri:ss. The 'redirect-uri' should hold the URI to a callback URL, which usually must be registered with the provider. The 'client-id' and 'client-secret' slots identifies the application and should be kept secret. For example, to initialize an oauth2 instance compatible with GitHub's api use:" +{ $unchecked-example + "\"https://github.com/login/oauth/authorize\"" + "\"https://github.com/login/oauth/access_token\"" + "\"https://localhost:8080\" \"client-id\" \"client-secret\"" + "\"user\" { } oauth2 boa" +} +"Then to get hold of an access token, use the " { $link console-flow } " word and enter the verification code given by the provider. This puts a " { $link tokens } " instance on the stack whose slot 'access' contains the actual access token. It can be used to make API calls on behalf of the user. For example, to list all the user's GitHub repositories:" +{ $unchecked-example + "\"https://api.github.com/user/repos\" \"access-token\"" + "oauth-http-get" +} +"Some providers limit the validity of the access token. If so, the provider sets the 'expiry' slot on the " { $link tokens } " tuple to the tokens expiration date and 'refresh' to a refresh token. The refresh token can be used with the " { $link refresh-flow } " word to request new access tokens from the provider." +{ $notes "The vocab only implements the console flow, but other methods for acquiring tokens could be added in the future" } ; + +ABOUT: "oauth2" diff --git a/extra/opengl/demo-support/demo-support-docs.factor b/extra/opengl/demo-support/demo-support-docs.factor new file mode 100644 index 0000000000..3798a8823e --- /dev/null +++ b/extra/opengl/demo-support/demo-support-docs.factor @@ -0,0 +1,8 @@ +USING: help.markup help.syntax opengl.gl quotations ; +IN: opengl.demo-support + +HELP: do-state +{ $values + { "mode" GLenum } + { "quot" quotation } +} { $description "Runs the quotation wrapped in a " { $link glBegin } "/" { $link glEnd } " block." } ; diff --git a/extra/processing/shapes/shapes.factor b/extra/processing/shapes/shapes.factor index 7114117064..840716d3d4 100644 --- a/extra/processing/shapes/shapes.factor +++ b/extra/processing/shapes/shapes.factor @@ -1,10 +1,8 @@ USING: alien.c-types alien.data arrays colors.constants grouping -kernel locals math math.vectors namespaces opengl opengl.gl -opengl.glu sequences sequences.generalizations shuffle ; +kernel locals math math.vectors namespaces opengl opengl.demo-support +opengl.gl opengl.glu sequences sequences.generalizations shuffle ; IN: processing.shapes -: do-state ( mode quot -- ) swap glBegin call glEnd ; inline - SYMBOL: fill-color SYMBOL: stroke-color diff --git a/extra/project-euler/039/039.factor b/extra/project-euler/039/039.factor index 1ad163d507..613e03a05c 100644 --- a/extra/project-euler/039/039.factor +++ b/extra/project-euler/039/039.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays kernel math math.ranges - namespaces project-euler.common sequences ; +USING: arrays kernel math math.ranges namespaces project-euler.common +sequences sequences.extras ; IN: project-euler.039 ! http://projecteuler.net/index.php?section=problems&id=39 @@ -56,7 +56,7 @@ PRIVATE> : euler039 ( -- answer ) [ - 1000 count-perimeters p-count get [ supremum ] keep index + 1000 count-perimeters p-count get arg-max ] with-scope ; ! [ euler039 ] 100 ave-time diff --git a/extra/project-euler/069/069.factor b/extra/project-euler/069/069.factor index 5094dcd674..1e7520f25c 100644 --- a/extra/project-euler/069/069.factor +++ b/extra/project-euler/069/069.factor @@ -1,7 +1,7 @@ ! Copyright (c) 2009 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: combinators fry kernel math math.primes math.primes.factors math.ranges - project-euler.common sequences ; +USING: combinators fry kernel math math.primes math.primes.factors +math.ranges project-euler.common sequences sequences.extras ; IN: project-euler.069 ! http://projecteuler.net/index.php?section=problems&id=69 @@ -47,7 +47,7 @@ PRIVATE> : euler069 ( -- answer ) 2 1000000 [a,b] [ totient-ratio ] map - [ supremum ] keep index 2 + ; + arg-max 2 + ; ! [ euler069 ] 10 ave-time ! 25210 ms ave run time - 115.37 SD (10 trials) diff --git a/extra/project-euler/070/070.factor b/extra/project-euler/070/070.factor index 499ce21c34..09f1098655 100644 --- a/extra/project-euler/070/070.factor +++ b/extra/project-euler/070/070.factor @@ -1,8 +1,9 @@ ! Copyright (c) 2010 Aaron Schaefer. All rights reserved. ! The contents of this file are licensed under the Simplified BSD License ! A copy of the license is available at http://factorcode.org/license.txt -USING: arrays assocs combinators.short-circuit kernel math math.combinatorics - math.functions math.primes math.ranges project-euler.common sequences ; +USING: arrays combinators.short-circuit kernel math math.combinatorics +math.functions math.primes project-euler.common sequences +sequences.extras ; FROM: project-euler.common => permutations? ; IN: project-euler.070 @@ -54,7 +55,7 @@ IN: project-euler.070 first2 { [ drop 7 10^ < ] [ permutations? ] } 2&& ; : minimum-ratio ( seq -- n ) - [ [ first2 / ] map [ infimum ] keep index ] keep nth first ; + [ [ first2 / ] map arg-min ] keep nth first ; PRIVATE> diff --git a/extra/project-euler/099/099.factor b/extra/project-euler/099/099.factor index 64c5533a69..36fae686d5 100644 --- a/extra/project-euler/099/099.factor +++ b/extra/project-euler/099/099.factor @@ -1,7 +1,8 @@ ! Copyright (c) 2008 Aaron Schaefer. ! See http://factorcode.org/license.txt for BSD license. -USING: io.encodings.ascii io.files kernel math math.functions math.parser - math.vectors sequences splitting project-euler.common ; +USING: io.encodings.ascii io.files kernel math math.functions +math.parser math.vectors project-euler.common sequences +sequences.extras splitting ; IN: project-euler.099 ! http://projecteuler.net/index.php?section=problems&id=99 @@ -39,7 +40,7 @@ IN: project-euler.099 flip first2 swap [ log ] map v* ; : solve ( seq -- index ) - simplify [ supremum ] keep index 1 + ; + simplify arg-max 1 + ; PRIVATE> diff --git a/extra/sequences/extras/extras-docs.factor b/extra/sequences/extras/extras-docs.factor index 53efced0d9..ac019d16d4 100644 --- a/extra/sequences/extras/extras-docs.factor +++ b/extra/sequences/extras/extras-docs.factor @@ -230,6 +230,16 @@ HELP: start-all* "{ 0 2 }" } } ; +HELP: arg-max +{ $values { "seq" sequence } { "n" integer } } +{ $description "Outputs the sequence with the largest item." } ; + +HELP: arg-min +{ $values { "seq" sequence } { "n" integer } } +{ $description "Outputs the sequence with the smallest item." } ; + +{ arg-max arg-min } related-words + HELP: count-subseq { $values { "subseq" sequence } { "seq" sequence } { "n" integer } } diff --git a/extra/sequences/extras/extras-tests.factor b/extra/sequences/extras/extras-tests.factor index 8d57d84b28..94830393e5 100644 --- a/extra/sequences/extras/extras-tests.factor +++ b/extra/sequences/extras/extras-tests.factor @@ -157,6 +157,7 @@ IN: sequences.extras.tests { { 1 3 5 } } [ 6 >array ] unit-test { 1 } [ { 1 7 3 7 6 3 7 } arg-max ] unit-test +{ 2 } [ { 0 1 99 } arg-max ] unit-test { 0 } [ { 1 7 3 7 6 3 7 } arg-min ] unit-test { V{ 0 4 } } [ { 5 3 2 10 5 } [ 5 = ] arg-where ] unit-test { { 2 1 0 4 3 } } [ { 5 3 2 10 5 } arg-sort ] unit-test diff --git a/extra/sequences/extras/extras.factor b/extra/sequences/extras/extras.factor index 06677d5f1b..5b927aacbc 100644 --- a/extra/sequences/extras/extras.factor +++ b/extra/sequences/extras/extras.factor @@ -411,10 +411,10 @@ INSTANCE: odds immutable-sequence [ dup empty? ] swap until drop ; inline : arg-max ( seq -- n ) - [ second-unsafe ] supremum-by first ; + [ supremum ] keep index ; : arg-min ( seq -- n ) - [ second-unsafe ] infimum-by first ; + [ infimum ] keep index ; , not necessarily in a factor buffer. | C-x 4 s | switch to other factor buffer in other window | | C-x 5 s | switch to other factor buffer in other frame | |--------------------+------------------------------------------------------------| - | M-. | edit word at point in Emacs (fuel-edit-word) | + | M-. | edit word/vocab at point in Emacs (fuel-edit-word-at-point)| | M-, | go back to where M-. was last invoked | | M-TAB | complete word at point | | C-c C-e u | update USING: line (fuel-update-usings) | | C-c C-e v | edit vocabulary (fuel-edit-vocabulary) | - | C-c C-e w | edit word (fuel-edit-word-at-point) | | C-c C-e d | edit word's doc (C-u M-x fuel-edit-word-doc-at-point) | | C-c C-e l | load vocabs in USING: form | |--------------------+------------------------------------------------------------| diff --git a/misc/fuel/fuel-base.el b/misc/fuel/fuel-base.el index 8044b11102..48d8026558 100644 --- a/misc/fuel/fuel-base.el +++ b/misc/fuel/fuel-base.el @@ -20,7 +20,6 @@ (interactive) (message "FUEL %s" fuel-version)) - ;;; Customization: ;;;###autoload @@ -28,9 +27,7 @@ "Factor's Ultimate Emacs Library." :group 'languages) - -;;; Utilities: - +;;; Compatibility with Emacs 24.3 (unless (fboundp 'setq-local) (defmacro setq-local (var val) (list 'set (list 'make-local-variable (list 'quote var)) val))) @@ -41,6 +38,11 @@ (list 'progn (list 'defvar var val docstring) (list 'make-variable-buffer-local (list 'quote var))))) +(unless (fboundp 'alist-get) + (defun alist-get (key alist) + (cdr (assoc key alist)))) + +;;; Utilities: (defun fuel-shorten-str (str len) (let ((sl (length str))) (if (<= sl len) str diff --git a/misc/fuel/fuel-connection.el b/misc/fuel/fuel-connection.el index cd5754cdec..19c2e97ea1 100644 --- a/misc/fuel/fuel-connection.el +++ b/misc/fuel/fuel-connection.el @@ -1,5 +1,6 @@ ;;; fuel-connection.el -- asynchronous comms with the fuel listener +;; Copyright (C) 2018 Björn Lindqvist ;; Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz ;; See http://factorcode.org/license.txt for BSD license. @@ -48,23 +49,11 @@ (defsubst fuel-con--request-p (req) (and (listp req) (eq (car req) :fuel-connection-request))) -(defsubst fuel-con--request-id (req) - (cdr (assoc :id req))) - -(defsubst fuel-con--request-string (req) - (cdr (assoc :string req))) - -(defsubst fuel-con--request-continuation (req) - (cdr (assoc :continuation req))) - -(defsubst fuel-con--request-buffer (req) - (cdr (assoc :buffer req))) - (defsubst fuel-con--request-deactivate (req) (setcdr (assoc :continuation req) nil)) (defsubst fuel-con--request-deactivated-p (req) - (null (cdr (assoc :continuation req)))) + (null (alist-get :continuation req))) ;;; TODO Replace with a defstruct (defsubst fuel-con--make-connection (buffer) @@ -78,24 +67,15 @@ (defsubst fuel-con--connection-p (c) (and (listp c) (eq (car c) :fuel-connection))) -(defsubst fuel-con--connection-requests (c) - (cdr (assoc :requests c))) - -(defsubst fuel-con--connection-current-request (c) - (cdr (assoc :current c))) - (defun fuel-con--connection-clean-current-request (c) (let* ((cell (assoc :current c)) (req (cdr cell))) (when req - (puthash (fuel-con--request-id req) req (cdr (assoc :completed c))) + (puthash (alist-get :id req) req (alist-get :completed c)) (setcdr cell nil)))) (defsubst fuel-con--connection-completed-p (c id) - (gethash id (cdr (assoc :completed c)))) - -(defsubst fuel-con--connection-buffer (c) - (cdr (assoc :buffer c))) + (gethash id (alist-get :completed c))) (defun fuel-con--connection-pop-request (c) (let ((reqs (assoc :requests c)) @@ -199,10 +179,10 @@ sexp. fuel-con-error is thrown if the sexp is malformed." (error (list 'fuel-con-error (format "%s" cerr)))))) (defun fuel-con--process-next (con) - (when (not (fuel-con--connection-current-request con)) - (let* ((buffer (fuel-con--connection-buffer con)) + (when (not (alist-get :current con)) + (let* ((buffer (alist-get :buffer con)) (req (fuel-con--connection-pop-request con)) - (str (and req (fuel-con--request-string req))) + (str (and req (alist-get :string req))) (cbuf (with-current-buffer (fuel-con--comint-buffer) (erase-buffer) (current-buffer)))) @@ -210,16 +190,16 @@ sexp. fuel-con-error is thrown if the sexp is malformed." (fuel-con--connection-cancel-timer con) (when (and buffer req str) (set-buffer buffer) - (fuel-log--info "<%s>: %s" (fuel-con--request-id req) str) + (fuel-log--info "<%s>: %s" (alist-get :id req) str) (comint-redirect-send-command (format "%s" str) cbuf nil t)))))) (defun fuel-con--process-completed-request (req) - (let ((cont (fuel-con--request-continuation req)) - (id (fuel-con--request-id req)) - (rstr (fuel-con--request-string req)) - (buffer (fuel-con--request-buffer req))) + (let ((cont (alist-get :continuation req)) + (id (alist-get :id req)) + (rstr (alist-get :string req)) + (buffer (alist-get :buffer req))) (if (not cont) - (fuel-log--warn "<%s> Droping result for request %S (%s)" + (fuel-log--warn "<%s> Dropping result for request %S (%s)" id rstr req) (condition-case cerr (with-current-buffer (or buffer (current-buffer)) @@ -231,7 +211,7 @@ sexp. fuel-con-error is thrown if the sexp is malformed." (defun fuel-con--comint-redirect-hook () (if (not fuel-con--connection) (fuel-log--error "No connection in buffer") - (let ((req (fuel-con--connection-current-request fuel-con--connection))) + (let ((req (alist-get :current fuel-con--connection))) (if (not req) (fuel-log--error "No current request") (fuel-con--process-completed-request req) (fuel-con--connection-clean-current-request fuel-con--connection))))) @@ -258,7 +238,7 @@ sexp. fuel-con-error is thrown if the sexp is malformed." (let ((con (fuel-con--get-connection buffer/proc))) (unless con (error fuel-con--error-message)) (let* ((req (fuel-con--send-string buffer/proc str cont sbuf)) - (id (and req (fuel-con--request-id req))) + (id (and req (alist-get :id req))) (time (or timeout fuel-connection-timeout)) (step 100) (waitsecs (/ step 1000.0))) diff --git a/misc/fuel/fuel-debug-uses.el b/misc/fuel/fuel-debug-uses.el index 119d17ad0e..c27d749d3a 100644 --- a/misc/fuel/fuel-debug-uses.el +++ b/misc/fuel/fuel-debug-uses.el @@ -109,7 +109,7 @@ (let* ((lines (fuel-debug--file-lines file)) (old-usings (fuel-debug--current-usings file)) (cmd `(:fuel ((V{ ,@old-usings } - [ V{ ,@lines } fuel-get-uses ] + [ ,file V{ ,@lines } fuel-get-uses ] fuel-use-suggested-vocabs)) t t))) (fuel-debug--uses-prepare file) (with-current-buffer (fuel-debug--uses-buffer) diff --git a/misc/fuel/fuel-edit.el b/misc/fuel/fuel-edit.el index 756f06550f..27e51ab2df 100644 --- a/misc/fuel/fuel-edit.el +++ b/misc/fuel/fuel-edit.el @@ -69,18 +69,6 @@ With prefix argument, refreshes cached vocabulary list." (fuel-edit--try-edit (fuel-eval--send/wait cmd)))) ;;;###autoload -(defun fuel-edit-word (&optional arg) - "Asks for a word to edit, with completion. -With prefix, only words visible in the current vocabulary are -offered." - (interactive "P") - (let* ((word (fuel-completion--read-word "Edit word: " - nil - fuel-edit--word-history - arg)) - (cmd `(:fuel* ((:quote ,word) fuel-get-word-location)))) - (fuel-edit--try-edit (fuel-eval--send/wait cmd)))) - (defun fuel-edit-word-at-point (&optional arg) "Opens a new window visiting the definition of the word at point. With prefix, asks for the word to edit." diff --git a/misc/fuel/fuel-eval.el b/misc/fuel/fuel-eval.el index 10be5fd793..374c5a56f9 100644 --- a/misc/fuel/fuel-eval.el +++ b/misc/fuel/fuel-eval.el @@ -46,7 +46,6 @@ (:nrs 'fuel-eval-non-restartable) (:in (or (factor-current-vocab) "fuel")) (:usings `(:array ,@(factor-usings))) - (:get 'fuel-eval-set-result) (:end '\;) (t `(:factor ,(symbol-name sexp)))))) ((symbolp sexp) (symbol-name sexp)))) @@ -144,8 +143,8 @@ (assoc name err)))) (defsubst fuel-eval--error-restarts (err) - (cdr (assoc :restarts (or (fuel-eval--error-name-p err 'condition) - (fuel-eval--error-name-p err 'lexer-error))))) + (alist-get :restarts (or (fuel-eval--error-name-p err 'condition) + (fuel-eval--error-name-p err 'lexer-error)))) (defsubst fuel-eval--error-file (err) (nth 1 (fuel-eval--error-name-p err 'source-file-error))) diff --git a/misc/fuel/fuel-help.el b/misc/fuel/fuel-help.el index de653c7182..c7d8455e81 100644 --- a/misc/fuel/fuel-help.el +++ b/misc/fuel/fuel-help.el @@ -328,7 +328,7 @@ With prefix, the current page is deleted from history." ("Show bookmarks..." "bb" fuel-help-display-bookmarks) ("Clean browsing history" "c" fuel-help-clean-history) -- - ("Edit word at point" "\M-." fuel-edit-word-at-point) + ("Edit word or vocab at point" "\M-." fuel-edit-word-at-point) ("Edit help file" "e" fuel-help-edit) -- ("Next page" "n" fuel-help-next) diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el index 2339b623f8..f33b6a67d7 100644 --- a/misc/fuel/fuel-listener.el +++ b/misc/fuel/fuel-listener.el @@ -274,8 +274,7 @@ the vocabulary name." (fuel-menu--defmenu listener fuel-listener-mode-map ("Complete symbol" ((kbd "TAB") (kbd "M-TAB")) fuel-completion--complete-symbol :enable (symbol-at-point)) - ("Edit word definition" "\M-." fuel-edit-word-at-point - :enable (symbol-at-point)) + ("Edit word or vocab at point" "\M-." fuel-edit-word-at-point) ("Edit vocabulary" "\C-c\C-v" fuel-edit-vocabulary) -- ("Word help" "\C-c\C-w" fuel-help) diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index cd8dd6a50c..3fd8a89c8c 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -145,7 +145,7 @@ ($quotation . fuel-markup--quotation) ($references . fuel-markup--references) ($related . fuel-markup--related) - ($see . fuel-markup--see) + ($see . fuel-markup--word-info) ($see-also . fuel-markup--see-also) ($shuffle . fuel-markup--shuffle) ($side-effects . fuel-markup--side-effects) @@ -155,7 +155,7 @@ ($subheading . fuel-markup--subheading) ($subsection . fuel-markup--subsection) ($subsections . fuel-markup--subsections) - ($synopsis . fuel-markup--synopsis) + ($synopsis . fuel-markup--word-info) ($syntax . fuel-markup--syntax) ($table . fuel-markup--table) ($tag . fuel-markup--tag) @@ -182,10 +182,10 @@ ((stringp e) (fuel-markup--insert-string e)) ((and (listp e) (symbolp (car e)) (assoc (car e) fuel-markup--printers)) - (funcall (cdr (assoc (car e) fuel-markup--printers)) e)) + (funcall (alist-get (car e) fuel-markup--printers) e)) ((and (symbolp e) (assoc e fuel-markup--printers)) - (funcall (cdr (assoc e fuel-markup--printers)) e)) + (funcall (alist-get e fuel-markup--printers) e)) ((listp e) (mapc 'fuel-markup--print e)) ((symbolp e) (fuel-markup--print (list '$link e))) (t (insert (format "\n%S\n" e))))) @@ -466,7 +466,7 @@ the 'words.' word emits." (fuel-markup--insert-newline))) (defun fuel-markup--all-tags (e) - (let* ((cmd `(:fuel* (all-tags :get) "fuel" t)) + (let* ((cmd `(:fuel* (all-tags) "fuel" t)) (tags (fuel-eval--retort-result (fuel-eval--send/wait cmd)))) (fuel-markup--list (cons '$list (mapcar (lambda (tag) (list '$link tag tag 'tag)) tags))))) @@ -484,7 +484,7 @@ the 'words.' word emits." (fuel-markup--insert-newline))) (defun fuel-markup--all-authors (e) - (let* ((cmd `(:fuel* (all-authors :get) "fuel" t)) + (let* ((cmd `(:fuel* (all-authors) "fuel" t)) (authors (fuel-eval--retort-result (fuel-eval--send/wait cmd)))) (fuel-markup--list (cons '$list (mapcar (lambda (a) (list '$link a a 'author)) authors))))) @@ -663,9 +663,13 @@ the 'words.' word emits." (defun fuel-markup--notes (e) (fuel-markup--elem-with-heading e "Notes")) -(defun fuel-markup--word-info (e s) +(defun fuel-markup--word-info (e) + "Uses the 'see' word to lookup info about a given word. Note +that this function is called in contexts where it is impossible +to guess the correct usings, so a static using list is used." (let* ((word (nth 1 e)) - (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) ,s) "fuel"))) + (cmd `(:fuel* ((:quote ,(symbol-name word)) see) + "fuel" ("kernel" "lexer" "see" "sequences"))) (ret (and cmd (fuel-eval--send/wait cmd))) (res (and (not (fuel-eval--retort-error ret)) (fuel-eval--retort-output ret)))) @@ -673,12 +677,6 @@ the 'words.' word emits." (fuel-markup--code (list '$code res) nil) (fuel-markup--snippet (list '$snippet " " word))))) -(defun fuel-markup--see (e) - (fuel-markup--word-info e 'see)) - -(defun fuel-markup--synopsis (e) - (fuel-markup--word-info e 'synopsis)) - (defun fuel-markup--null (e)) diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index 043ef1c97d..072291cdfc 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -185,9 +185,8 @@ interacting with a factor listener is at your disposal. ("Eval region" ("\C-c\C-e\C-r" "\C-c\C-er") fuel-eval-region :enable mark-active) -- - ("Edit word at point" ("\M-." "\C-c\C-e\C-d" "\C-c\C-ed") - fuel-edit-word-at-point :enable (symbol-at-point)) - ("Edit word..." ("\C-c\C-e\C-w" "\C-c\C-ew") fuel-edit-word) + ("Edit word or vocab at point..." ("\M-." "\C-c\C-e\C-d" "\C-c\C-ed") + fuel-edit-word-at-point) ("Edit vocab..." ("\C-c\C-e\C-v" "\C-c\C-ev") fuel-edit-vocabulary) ("Jump back" "\M-," fuel-edit-pop-edit-word-stack) -- diff --git a/misc/fuel/fuel-scaffold.el b/misc/fuel/fuel-scaffold.el index d496e37892..ae0091b933 100644 --- a/misc/fuel/fuel-scaffold.el +++ b/misc/fuel/fuel-scaffold.el @@ -27,13 +27,6 @@ "Options for FUEL's scaffolding." :group 'fuel) -(defcustom fuel-scaffold-developer-name nil - "The name to be inserted as yours in scaffold templates." - :type '(choice string - (const :tag "Factor's value for developer-name" nil)) - :group 'fuel-scaffold) - - ;;; Auxiliary functions: (defun fuel-mode--code-file (kind &optional file) @@ -50,15 +43,15 @@ (fuel-mode--code-file "tests")) (defun fuel-scaffold--vocab-roots () - (let ((cmd '(:fuel* (vocab-roots get :get) "fuel" ("namespaces" "vocabs.loader")))) + (let ((cmd '(:fuel* (vocab-roots get) + "fuel" ("namespaces" "vocabs.loader")))) (nth 1 (fuel-eval--send/wait cmd)))) (defun fuel-scaffold--dev-name () - (or (let ((cmd '(:fuel* (developer-name get :get) + (or (let ((cmd '(:fuel* (developer-name get) "fuel" ("namespaces" "tools.scaffold")))) (fuel-eval--retort-result (fuel-eval--send/wait cmd))) - fuel-scaffold-developer-name user-full-name "Your name")) @@ -148,8 +141,8 @@ IN: %s adds source and authors.txt files. Prompts the user for optional summary, tags, help, and test file creation. -You can configure `fuel-scaffold-developer-name' for the name to -be inserted in the generated files." +You can configure `user-full-name' for the name to be inserted in +the generated files." (interactive) (let* ((name (read-string "Vocab name: " name-hint)) (root (completing-read "Vocab root: " @@ -160,8 +153,8 @@ be inserted in the generated files." (platforms (read-string "Vocab platforms (empty for all): ")) (help (y-or-n-p "Scaffold help? ")) (tests (y-or-n-p "Scaffold tests? ")) - (cmd `(:fuel* ((,root ,name ,(fuel-scaffold--dev-name) - (fuel-scaffold-vocab)) "fuel"))) + (cmd `(:fuel* (,root ,name ,(fuel-scaffold--dev-name) + fuel-scaffold-vocab) "fuel")) (ret (fuel-eval--send/wait cmd)) (file (fuel-eval--retort-result ret))) (unless file @@ -186,7 +179,7 @@ be inserted in the generated files." scaffolded help for each word in the current vocabulary. With prefix argument, ask for the vocabulary name. You can -configure `fuel-scaffold-developer-name' for the name to be +configure `user-full-name' for the name to be inserted in the generated file." (interactive "P") (let* ((vocab (or (and (not arg) (factor-current-vocab)) @@ -204,8 +197,8 @@ inserted in the generated file." vocabulary. With prefix argument, ask for the vocabulary name. You can -configure `fuel-scaffold-developer-name' for the name to be -inserted in the generated file." +configure `user-full-name' for the name to be inserted in the +generated file." (interactive "P") (let* ((vocab (or (and (not arg) (factor-current-vocab)) (fuel-completion--read-vocab nil))) @@ -221,7 +214,7 @@ inserted in the generated file." vocabulary. With prefix argument, ask for the vocabulary name. You can -configure `fuel-scaffold-developer-name' for the name to be +configure `user-full-name' for the name to be inserted in the generated file." (interactive "P") (let* ((vocab (or (and (not arg) (factor-current-vocab)) diff --git a/misc/fuel/fuel-stack.el b/misc/fuel/fuel-stack.el index 51642372cb..bccda83024 100644 --- a/misc/fuel/fuel-stack.el +++ b/misc/fuel/fuel-stack.el @@ -52,7 +52,7 @@ Set it to 0 to disable highlighting." (defun fuel-stack--infer-effect (str) (let ((cmd `(:fuel* ((:using stack-checker effects) - ([ (:factor ,str) ] infer effect>string :get))))) + ([ (:factor ,str) ] infer effect>string))))) (fuel-eval--retort-result (fuel-eval--send/wait cmd 500)))) (defsubst fuel-stack--infer-effect/prop (str) diff --git a/vm/layouts.hpp b/vm/layouts.hpp index 7975f4ca92..e60201ed5d 100644 --- a/vm/layouts.hpp +++ b/vm/layouts.hpp @@ -104,7 +104,7 @@ inline static fixnum untag_fixnum(cell tagged) { } inline static cell tag_fixnum(fixnum untagged) { - return (untagged << TAG_BITS) | FIXNUM_TYPE; + return ( (cell)untagged << TAG_BITS) | FIXNUM_TYPE; } #define NO_TYPE_CHECK static const cell type_number = TYPE_COUNT