| ###################################################################### | http://CoSy.com | ###################################################################### | | Tap F1 for Help | First Lesson : On a blank line below : tap F12 . tap Enter . write something . tap F11 . __________________________________________________________________________ Today 30 _i Daylns | Create 30 calendar daysTap F6 , Tap F5 to insert __________________________________________________________________________ You have now made and saved your first timeStamped notes | Think of CoSy as intelligent paper | | Skip down to bottom of log for most current work | | ====================================================================== | | A ` word in Forth is any non blank string of characters | | \/ \/ \/ | F6 executes the line under the cursor | \/ \/ \/ | | The syntax of Forth is { parse-a-word doIt repeat } | | \/ | Put the cursor on lines below and tap F6 | \/ | s" Hello World " | return a CoSy character list , ie: string . HelloPrize | F6 this to find out your prize ! | 20190510.1322 | s" Hello World " reverse | See ! it was sitting on Top of Stack s" Hello World " # | ` rho is APL for ` count number of items . | In Forth , a "word" can be any non-blank string of characters delimited by white space | That's why ' s" has to have a blank separating it from the quoted phrase | Forth syntax is simply read-a-word do-it | The word : adds new words to the Forth dictionary ; ends compiling mode : HelloWorld s" Hello World " ; | define the word ' HelloWorld HelloWorld | ( to be saved needs to be added to script HelloWorld i( 7 23 )i take >t0> | Here's an APLish demo t0 ' # 'm t0 t0 dup ' reverse 'm ' cL 'd | execute each line in turn to see R0 dup reverse cL | what Forth CoSy APL vocabulary can do . | NB : vocabulary is case sensitive | | ====================================================================== | | Historical note : | ` NB , short for Nota Bene == Note Well , was a favorite of Ken Iverson | | ###################################################################### | EVERYTHING IS A LIST ITEMS MAY BE LISTS http://cosy.com/CoSy/4th.CoSy.html#CoSyHeader A CoSy list header consists of the first 3 cells : `( Type # Ref# )` `( Type # Ref# )` ' :?? 'm A DICTIONARY IS A LIST OF 2 LISTS | ( Names ; Values ) The "Root" dictionary is named ` R ' R the ` Root dictionary containing entire working environment Is saved before each execution . R `( Type # Ref# )` ' Eval 'R ` text Dv@ VOCABULARY on LISTS R # | APL word "count" # of items in list aka ` rho | raw : i# R ' # 'm | count each ( monadic ) | used so often , also | rho' same as R { # } 'm R dnames | names in Root ( ` R ) dictionary . Same as | R dsc Dnames | names in current dictionary intially the Root ( ` R ) dictionary . | ###################################################################### | F1 : Basic Help | Tapping the F1 key lists all key shortcuts . ` ?? ?? | all occurences of a word in the files listed in `( sys CoSySource )` | equivalent to s" ??" ?? | these actually return lines found delimite by totally empty lines | NB: tick , ` , makes the next word into a string . | thus s" asdf" ` asdf match |>| 1 ` See :?? | colon definition of a word equivalent to s" : See" ?? | Other help words : ` Help :?? | Reva help on Reva word . These may not be in ` CoSySource files ` See :?? | x86 code for a definition . Needs improvement . Xwords >t0> | all words in all contexts t0 flip 1 _at "bl MV blVM | strung out into list of words . | \/ | NB : Note the difference between ` and ' . Here are their definitions ` ` :?? | return next word as a string | versus ` ' Help | the address of a raw Reva Forth definintion . To test if a word exists : ' asdf _i | returns address if defined else 0 | | or ` asdf See | | essential words on the top left of keyboard : `( ` ! @ # $ )` ` | returns next word in input as a non-blank string ! | ( n a -- ) store n at address a @ | ( a -- n ) return contents of address a # | return ` count , number of items , of CoSy list $ | swap aka ` --ba | each of these have variants with associated meanings | \/ \/ \/ \/ | Other help sources | \/ \/ \/ \/ | ` help -> ` examples -> | /\ /\ /\ /\ | Other help sources | /\ /\ /\ /\ | | ====================================================================== | | \/ \/ \/ | Raw Reva Forth ( sF6 ) | \/ \/ \/ | One can now stay fairly easily executing at the 4th.CoSy list level using F6 . But tapping shift F6 simply executes raw Forth leaving things on the stack sF6 does not try to output the top item . 1 2 - . | /\ /\ /\ | Raw Reva Forth ( sF6 ) | /\ /\ /\ | | ======================================================================= | | \/ \/ \/ | 4th.Cosy ( F6 ) | \/ \/ \/ | ` @ Help | Help on Reva word ' @ | zic Help | gives overall Help res> blVM ' Help 'm | show help on each word in a string . | Reva help often lists related words at the end of a definition . | I often edit down the ` res contents down to these lists | and then use a line like this to display all the related word . | EXERCISE | Make a word to automate this extraction . ` @ See | See x86 code for ' @ | equivalent to APL commute ` @ Words | words containing s" @" . Note : just in the CoSy context | EVERYTHING is a LIST | | Dictionaries are lists of a pair of lists of associated names and values | This ` text and ` res are items in the ' R root dictionary saved by ctrl_s R # |>| 2 | ' # , aka ' rho is the K , APL word for number of items . ' i# is raw count , the second cell in list headers . | 3 generic functions | cognates of Forth | ' address | @ Fetch | ! Store ; | | ix i@ i! | ( lst i -- r ) | Raw Indexing | vx v@ V! | ( lst _i -- r ) | indexing by name on dictionaries | Dvx Dv@ Dv! | ( _i -- r ) | same using ' _d ( Root ) dictionary | at at! | ( lst iv -- r ) | top level get and put | TYPES | | simple | | character , byte , strings | s" asdf\qwert.code " | Strings ( bytes ) | since 20180306 | Note that the quote character itself cannot be in a string . | Reva's " uses \ to escape the " character so it can be included in strings . | ' s/" retains that behavior . Thus to get help on ' s" itself use : s/" s\" " ?? | Thus must use s/" \\ " and s/" \" " to embed these chars in strings `( LF CR HT BL )` { Eval _i } 'm ,/ | basic raw char constants zic s" " match |>| 1 | ' zic is an empty string `( asdf sym )` ` asdf ` sym ,L match |>| 1 | word lists | numeric lists | i( 0 1 2 3 )i | integers also | 123 _i | 123 456 2_i | f( 2.28 2 2.e5 )f | Floats also | 3.14 ' _f | 3.14 2. 2_f | Forth variable sigdig sets output decimals . Set in ` script0 | general s" asdf " i( 0 1 2 )i ,L | general lists . this creates a list of 2 items -1 _i i( 0 1 2 )i cL | same a ' ,L but catinates if same type | Evaluated list | (' .... ') | evaluates text between and makes result into | a list . Eg: a ledger entry : (' 20200615.1047 _f ` PSBT ` PayPalBL 21.32 _f s" JR cigar " ') | >>> MODULO indexing <<< | Some numerical examples : 12 _iota i( 1 0 -1 )i +i | Put the cursor on this line and tap F6 . See ` res above 12 _iota >t0> | It's "concatinative" we can split it and execute parts i( 1 0 -1 )i >t1> | t0 and t1 are convenence variables . t0 t1 +i | See ` examples | -------------------------------------------------------------------------- | | \/ \/ \/ | Iterators | \/ \/ \/ | A great deal of power of APL languages comes from ` adverbs , which APL calls ` operators , which take a verb ( function ) along with an noun or nouns ( data ) as arguments . These are easy to implement in Forth's RPN syntax with the use of the word ' which returns the address of the word following rather than executing the word itself . The construction { .... } also creates a verb leaving its address ( xt ) on the stack . Perhaps the quintessential APL adverb is ` each . CoSy follows Arthur Whitney in implementing 4 forms : RA ' verb 'm | monadic each . Applies verb to each item of RA LA RA ' verb 'd | dyadic each . Applies verb to each corresponding pair | of items in LA and RA . LA RA ' verb 'L | applies verb to RA and each item of LA LA RA ' verb 'R | applies verb to LA and each item of RA Note that while the current single thread implementation of CoSy the arguments are iterated thru , there is no implication of sequenciality . The definitions are intrinsically parallel . Note also that modulo indexing extends a shorter list to match a longer . | /\ /\ /\ | Iterators | /\ /\ /\ | | -------------------------------------------------------------------------- | | \/ \/ \/ | SCANS | \/ \/ \/ | RA ' verb ./ | across | eg: ' +i ./ | sum integers RA ' verb .\ | scan | acumulating sums , eg: running balance . | /\ /\ /\ | 4th.Cosy ( F6 ) | /\ /\ /\ | | ====================================================================== | | ###################################################################### | | \/ \/ \/ | Tek Log | \/ \/ \/ | ` .\CoSy\WorkLog.csy startJob | F6 to start persistent work space ` ./CoSy/Presentations.csy startJob | Collected Presentations and Demos | ======================== | Wed.Jun,20200603 | ======================== | | I've decided to spilt off my log of ongoing work to a separate Job | which always has simply been here , but likely more confusing than illuminating | /\ /\ /\ | Tek Log | /\ /\ /\ | | ###################################################################### | | ======================== | Sat.Jul,20200718 | ======================== | Dnames R dsc `( Fact Fact )` Dv@ >t1> | ` morse v@ flip ` Bugs Dvdel i( 1 2 3 5 )i 20 _iota at | ======================== | Sat.Nov,20201107 | ======================== | d1 @ _getPos `( sys Tui posXY )` Dv! | Stores current upper left corner for restart bye | ###################################################################### | | ======================== | e o current work | ======================== | | ###################################################################### | | \/ \/ \/ | PLEASE ASK ANY QUESTIONS at | \/ \/ \/ | http://www.cosy.com/CoSy/AskMeAnything.html | /\ /\ /\ | PLEASE ASK ANY QUESTIONS at | /\ /\ /\ | | JOIN THE CoSy alphas . SUBSCRIBE at http://CoSy.com | ~~ | \/ | sometimes useful lines | \/ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ec Words .. ` =c conn 10 _-+ ,/ at reverse ` around ?? t1 ` Eval conn ` cf9 ?? res> >t1> t0 F> >t1> rShow res> lfMV rUpdate rGet >t1> lf>nl ` ./CoSy/CoSy.f >F t1 lfVM .. ` =c conn 10 _-+ ,/ at Dnames 4 _partition ' blMV 'm ` ./CoSy/CoSy.f F> ` ./CoSy/CoSy.f.bk >F ec Dir forgettst ` tstScript -> | Test script for interactively editing multiline fns ` tstScript Dv@ ^eval | save . Then execute to redefine . R0 DMP cr ev >R0 R0 DMP | sF6 . useful for executing when ' save bombs Dnames | { Dv@ rho } 'm | lst | sF6 . check if any ' rho' crazy ` .\CoSy dir s" .\CoSy\CoSy.bk" F> str>lst ` help v@ rho mark forget ` ./CoSy/math.f F> | Eval R0 >t0> F> >t1> ^eval | for editing or evaluating a file res> "lf "nl ,L ssr t0 >F R 1 _at ' rho 'm | == | SETTING DISPLAY PARAMETERS | ` script0 -> | show , edit final startup script . set display parameters ` script0 Dv@ Eval | execute ` script0 startup script | normally executed on start up | CoSy needs to be restarted for changes in the display to take effect . | == | 2 sigdig ! bye |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| |/\| | ###################################################################### | ` SkriptThots -> | 20190913.1341 | 20190427.1154 | 20200508.1253 | MY IGNORANCE OF ANYTHING OTHER THAN APL>K FORTH CAN'T BE OVERESTIMATED OPEN FROM THE MATH TO THE CHIP | PRACTICAL | AMBIENT | IRRITATION DRIVEN DEVELOPEMENT if can't execute each line as you compose a verb , not competitive . Forth gains tremendous power by not doing things . REPL | IDE | nested ( recursive ) ' { ' } | clean quotations ~ ['] | Levels of consolidated vocabulary dFns tacit | ` adicity text> | HelloPrize text> `( .r text )` Dv! `D@ .r dup setWdo showWdo TO REACH COMERCIAL PRODUCT : WEB APP ` ToDo -> | /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ | | ###################################################################### | |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| |\/| | \/ | Line to make more calendar | \/ | Needs updating | s" 1 8 2020 30 daylns " forth> | insert res in text using F5 | /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ | ` - 70 _take s" | " enc braket | ---------------------------------------------------------------------- | | ====================================================================== | | ###################################################################### | | ###################################################################### |