X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=extra%2Frpn%2Frpn.factor;h=dc8ec7b139b6cc0fe3531b85da090ec13ad72701;hp=ba697df8d1039f4ad489f571ad4a7c00f5820963;hb=HEAD;hpb=01a4047126a253a0cbe46c0aee627a4fd0b74174 diff --git a/extra/rpn/rpn.factor b/extra/rpn/rpn.factor index ba697df8d1..e7ea4baf9f 100644 --- a/extra/rpn/rpn.factor +++ b/extra/rpn/rpn.factor @@ -1,5 +1,5 @@ ! Copyright (C) 2009 Slava Pestov -! See http://factorcode.org/license.txt for BSD license. +! See https://factorcode.org/license.txt for BSD license. USING: accessors combinators io kernel lists math math.parser sequences splitting ; IN: rpn @@ -10,7 +10,7 @@ TUPLE: push-insn value ; GENERIC: eval-insn ( stack insn -- stack ) : binary-op ( stack quot: ( x y -- z ) -- stack ) - [ uncons uncons [ swap ] dip ] dip dip cons ; inline + [ uncons uncons swapd ] dip dip cons ; inline M: add-insn eval-insn drop [ + ] binary-op ; M: sub-insn eval-insn drop [ - ] binary-op ; @@ -19,7 +19,7 @@ M: div-insn eval-insn drop [ / ] binary-op ; M: push-insn eval-insn value>> swons ; : rpn-tokenize ( string -- string' ) - " " split harvest sequence>list ; + split-words harvest sequence>list ; : rpn-parse ( string -- tokens ) rpn-tokenize [