NB. J standard definitions for CS2322 NB. Usually read into the z locale NB. Set output parms so we see everything. NB.(9!:37) 0 1000000 0 1000000 NB. Explicit definition noun =: 0 adverb =: 1 conj =: 2 verb =: 3 monad =: 3 dyad =: 4 locale =: 6 tacit =: 13 def =: : NB. Miscelaneous read_z_ =: 1 !: 1 @ < write_z_ =: (1 !: 2) < write_append_z_ =: (1 !: 3) < write_data_z_ =: dyad def 0 x. =. , (format x.) ,. 10 { a. minus =. (x. = '_') # i. # x. ('-' minus } x.) write y. ) write_append_data_z_ =: dyad def 0 x. =. , (format x.) ,. 10 { a. minus =. (x. = '_') # i. # x. ('-' minus } x.) write_append y. ) plot_z_ =: monad def 0 nl =. 10 { a. y. write_data 'plot.out' ('set autoscale y',nl)write'plot.cmd' NB.('set yrange[',(": <./ 1{"1 y.),':',(": >./ 1{"1 y.),']',nl)write_append'plot.cmd' NB.('set xrange[',(": <./ 0{"1 y.),':',(": >./ 0{"1 y.),']',nl)write_append'plot.cmd' ('plot "plot.out" with lines', nl )write_append'plot.cmd' ('pause -1' , nl) write_append 'plot.cmd' system'gnuplot plot.cmd' ) help =: monad def 'jhelp''netscape''' time =: 6 !: 2 space =: 7 !: 2 format =: ": names =: > @ (4 !: 1) system =: 2 !: 0 spawn_z_ =: 2 !: 1 ed =: vi =: spawn_z_ &('vi '&,) gedit =: spawn_z_ &('gedit '&,) emacs =: spawn_z_ &('emacs '&,) xemacs =: spawn_z_ &('xemacs '&,) gxedit =: spawn_z_ &('gxedit '&,) gnuplot =: spawn_z_ &('gnuplot '&,) gnp =: spawn_z_ &('gnp '&,) gvim =: spawn_z_ &('gvim '&,) representation =: 5 !: 1 & < linear =: 5 tree =: 4 boxed =: 2 atomic =: 1 query_display =: 9!:2 set_display =: 9!:3 box_chars =: (9!:7) & (1 0 2 3 4 5 & {) & (9!:6) roll =: ? do =: ". log_session =: (0 !: 1 & 1) @ < print_precision =: 9 !: 10 set_print_precision =: 9 !: 11 over =: ({.;}.)@":@, by =: ' '&;@,.@[,.] table =: adverb def '[ by ] over x./' atop =: @ bond =: & rank =: " numberp =: monad def '+/1 4 8 16 64 e. 3 !: 0 y.' charp =: monad def '2 = 3!:0 y.' boxp =: monad def '32 = 3!:0 y.' transpose =: |: rotate =: |. cat =: monad def 'system ''cat '',y.' cut =: ;. box_cut =: < cut NB. Tracing display_z_ =: 1 !: 2 & 2 trace_z_ =: monad def 0 display_z_ y. : display_z_ (format x.),format y. y. ) entering =: 'Entering, input = '&trace_z_ leaving =: 'Leaving, result = '&trace_z_ error =: % atop display atop format erase =: 4 !:55 @ < NB. Standard Input/Output stdin_z_ =. monad def 'read_z_ 1' stdout_z_ =. write_z_ & 2 NB. Introduction tally =: # copy =: # shape =: $ reshape =: $ first =: {. rest =: }. append =: , integer =: i. box =: < open =: > link =: ; NB. Computer Organization rep =: #: base =: #. NB. Computer Circuits from =: { and =: *. or =: +. amend =: } take =: {. drop =: }. insert =: / NB. Data Structures reverse =: |. not =: -. last =: _1 & from drop_last =: _1 & drop match =: -: head =: open atop first nullp =: (0 bond =) atop tally NB. Object Programming make_z_ =: 0 !: 0 @ < for_effect_only_z_ =: monad def '''unspecified''' invalid_method_name_indicator_z_ =: 'unknown' root_object_z_ =: monad def 0 ('method' ; 'value') =. 2 take y. if. method -: 'type' do. 'root object' else. 'In root object: ',method,': Invalid method name.' end. ) NB. Programming Methodology to_char =: 3 !: 1 to_internal =: 3 !: 2 write_list =: dyad def '(to_char x.) write y.' write_append_list =. dyad def '(to_char x.) write_append y.' read_list =: to_internal @ read NB. Software Engineering gcd =: +. NB. Language Translation word =: ;: NB. Computability residue =: | NB. Artificial Intelligence stitch =: ,. not_equal =: ~: index_of =: i. ravel =: ,