Guest User

dict.fth

a guest
Jun 17th, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.09 KB | None | 0 0
  1. [UNDEFINED] 1place [IF] : 1place swap rot drop ; [THEN]
  2. [UNDEFINED] 2pick [IF] : 2pick 2 pick ; [THEN]
  3. [UNDEFINED] addi [IF] : addi over + ; [THEN]
  4. [UNDEFINED] cell- [IF] : cell- -1 cells + ; [THEN]
  5. [UNDEFINED] char- [IF] : char- -1 chars + ; [THEN]
  6. [UNDEFINED] dropdrop0 [IF] : dropdrop0 drop drop 0 ; [THEN]
  7. [UNDEFINED] neqn [IF] : neqn 2dup <> ; [THEN]
  8. [UNDEFINED] 1cells/ [IF] : 1cells/ 1 cells / ; [THEN]
  9.  
  10.  
  11. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  12. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  13. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  14. \
  15. \
  16. \ Memory-based stacks are useful for many things. Here are
  17. \ some words for handling them:
  18. \
  19. \ stack format:
  20. \
  21. \ pStk+0c: data pointer
  22. \ pStk+1c: initial pointer (only required for stk.{bottom,
  23. \ clear,depth,empty?,full?})
  24. \ pStk+2c: allocated size (only used in stk.{free,full?})
  25. \
  26. \ pStk+3c+: data region (optional... may reside elsewhere,
  27. \ starting at wherever "initial pointer"
  28. \ (pStk+1c) points but stk.create
  29. \ puts it here)
  30. \
  31. \ Rudimentary stacks could just have a data pointer (pStk+0c),
  32. \ so long as only the words stk.{next,top,set,push,pull,pop,drop}
  33. \ are used. Including the initial pointer (pStk+1c) allows for
  34. \ using the words stk.{bottom,clear,depth,empty?}. Such stacks
  35. \ could be created at "here" with "dup , ," ( pInit -- ). [see
  36. \ stk.bounds_checking caveats, below]
  37.  
  38. : stk._aus 3 + cells ; ( size -- cells ) \ number of address units needed by a stack of the given size
  39.  
  40. : stk.next @ ; ( pStk -- pNext ) \ Next address for the stack
  41. : stk.bottom cell+ @ ; ( pStk -- pBottom ) \ Address of the first data pushed
  42. : stk.size 2 cells + @ ; ( pStk -- cells ) \ Number of cells allocated for the stack
  43.  
  44. : stk._set ! ; ( pNext pStk -- ) \ Set the stack pointer to the given value
  45. : stk.top stk.next cell- ; ( pStk -- pTop ) \ Address of the last data pushed
  46.  
  47. : stk.reset dup stk.bottom swap stk._set ; ( pStk -- ) \ Empty the stack
  48.  
  49. : stk.depth dup stk.next swap stk.bottom - 1cells/ ; ( pStk -- depth ) \ Number of elements in the stack
  50. : stk.empty? dup stk.next swap stk.bottom = ; ( pStk -- -1|0 ) \ Whether or not the stack is empty
  51. : stk.full? dup stk.depth swap stk.size = ; ( pStk -- -1|0 ) \ Whether or not the stack is full
  52.  
  53. : stk.push dup stk.next tuck cell+ swap stk._set ! ; ( data pStk -- ) \ Push data on the stack
  54. : stk.pull dup stk.next tuck cell+ swap stk._set @ ; ( pStk -- data ) \ Pull from stk.next and increment pointer, as though it's really a queue tail
  55. : stk.pop dup stk.top tuck swap stk._set @ ; ( pStk -- data ) \ Pop data off the stack and return the value popped
  56. : stk.drop dup stk.top swap stk._set ; ( pStk -- ) \ Drop data off the stack without returning it
  57. : stk.pick stk.top swap negate cells + @ ; ( u pStk -- d ) \ Pick the u'th element from the top of stack
  58. : stk.place stk.top swap negate cells + ! ; ( d u pStk -- ) \ Place d as the u'th element from the top of stack
  59.  
  60. \ initialize the stack at memory pStk to the given size
  61. : stk._init ( size pStk -- )
  62. dup 3 cells + 2dup over ! cell+ ! 2 cells + !
  63. ;
  64.  
  65. \ Create a stack of the specified size at "here", and return what "here" was
  66. : stk.allot ( size -- pStk )
  67. align here tuck over stk._aus allot stk._init
  68. ;
  69.  
  70. \ Create a stack of the specified size at "here", store the stack in <name>
  71. : stk.create ( size "<name>" -- )
  72. stk.allot constant
  73. ;
  74.  
  75. \ Create a stack of the specified size in dynamic memory or throw an exception
  76. : stk.allocate ( size -- pStk )
  77. dup stk._aus allocate throw tuck stk._init
  78. ;
  79.  
  80. \ Deallot the space for this stack if it's at the top of the data space
  81. : stk.deallot ( pStk -- )
  82. dup stk.size 3 + cells
  83. swap addi here <> abort" stk.deallot: can't free stack"
  84. negate allot
  85. ;
  86.  
  87. \ Deallocate the space for this stack
  88. : stk.free ( pStk -- )
  89. free throw
  90. ;
  91.  
  92. \ Execute xt ( n -- ) for each element, n, on the stack, from deepest to topmost.
  93. : stk.foreach ( xt pStk -- )
  94. swap >r
  95. dup stk.next
  96. swap stk.bottom
  97. begin
  98. neqn
  99. while
  100. dup @ r@ execute
  101. cell+
  102. repeat
  103. 2drop
  104. r> drop
  105. ;
  106.  
  107. \ Show the stack elements
  108. : stk.emit ( pStk -- )
  109. [char] < emit
  110. dup stk.depth 0 .r
  111. ." > "
  112. ['] . swap stk.foreach
  113. ;
  114.  
  115. \ When stk.bounds_checking is enabled, stk.{pop,drop} also need
  116. \ pStk+1c to be properly initialized, and stk.{push,pull} need
  117. \ pStk+1c and pStk+2c to be properly initialized, since they will
  118. \ call stk.empty? and stk.full?, respectively.
  119.  
  120. [DEFINED] stk.bounds_checking [IF]
  121. : stk.not_empty dup stk.empty? abort" stk.not_empty: stack empty" ;
  122. : stk.not_full dup stk.full? abort" stk.not_full: stack full" ;
  123. : stk.index? stk.depth u< 0= abort" stk.index?: stack index out of range" ;
  124.  
  125. : stk.push stk.not_full stk.push ;
  126. : stk.pull stk.not_full stk.pull ;
  127. : stk.pop stk.not_empty stk.pop ;
  128. : stk.drop stk.not_empty stk.drop ;
  129.  
  130. : stk.pick 2dup stk.index? stk.pick ;
  131. : stk.place 2dup stk.index? stk.place ;
  132. [THEN]
  133.  
  134.  
  135.  
  136. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  137. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  138. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  139. \
  140. \ A small, general-purpose temporary stack to be used when
  141. \ needed, particularly to help support re-entrancy of functions.
  142. \ The value tmp_stack is adjustable, in case the user wishes to
  143. \ make a larger stack (even temporarily) for their purposes:
  144. \
  145. \ tmp_stack
  146. \ 256 stk.allocate to tmp_stack
  147. \ >t
  148. \ [... use ">t", "t>", etc., with larger stack... ]
  149. \ t>
  150. \ tmp_stack stk.free
  151. \ to tmp_stack
  152.  
  153. 0 value tmp_stack
  154. 16 stk.allot to tmp_stack
  155. : >t tmp_stack stk.push ;
  156. : t> tmp_stack stk.pop ;
  157. : t@ tmp_stack stk.top @ ;
  158. : t! tmp_stack stk.top ! ;
  159. : .t tmp_stack stk.emit ;
  160.  
  161.  
  162.  
  163. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  164. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  165. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  166. \
  167. \ The 'str' objects represent reduced string capabilities.
  168. \ They are not guaranteed to support lengths greater than 255
  169. \ nor to allow nul characters. Their implementation is not
  170. \ specified to be any particular form, just that the following
  171. \ methods are supported:
  172. \
  173. \ str.aus ( u -- aus )
  174. \ str.place ( c-addr u str -- )
  175. \
  176. \ str.cpy ( c-addr u -- str )
  177. \ str.dup ( str1 -- str2 )
  178. \ str.tail ( str1 u -- str2 )
  179. \ str.head ( str1 u -- str2 )
  180. \ str.cat ( str1 str2 -- str3 )
  181. \ str.deallot ( str -- )
  182. \
  183. \ str.chars ( str -- c-addr )
  184. \ str.len ( str -- len )
  185. \ str.cmp ( str1 str2 -- -1|0|1 )
  186. \ str.= ( str1 str2 -- 0|-1 )
  187. \ str.< ( str1 str2 -- 0|-1 )
  188. \ str.foreach ( xt str -- )
  189. \ str.emit ( str -- )
  190. \ str.c, ( str -- )
  191. \
  192. \ The words str.{cpy,dup,tail,head,cat} create new 'str' objects
  193. \ at "here", calling "allot" to create space. The word
  194. \ str.deallot attempts to free a 'str' object, but may silently
  195. \ fail if "here" is different from the time just after the
  196. \ object was created, leaving the memory to leak.
  197.  
  198. \ [The implmentation below uses null-terminated strings, yet
  199. \ there is still no general guarantee that a 'str' object
  200. \ can store more than 255 characters, since other implementations
  201. \ may opt for counted-string formats.]
  202.  
  203. \ the number of address units (aus) needed to store a string
  204. \ with the specified number of characters
  205. : str.aus ( u -- aus )
  206. 1+ chars
  207. ;
  208.  
  209. \ initialize the 'str' object with the 'u' non-nul characters
  210. \ found starting at 'c-addr'. 'str' must be an address for a
  211. \ memory region of at least size "u str.aus". any previous
  212. \ data in the region will be lost.
  213. : str.place ( c-addr u str -- )
  214. >r chars tuck r@ swap move
  215. r> + 0 swap c!
  216. ;
  217.  
  218. \ make a 'str' object, possibly at "here", with the 'u' non-nul
  219. \ characters found starting at 'c-addr'
  220. : str.cpy ( c-addr u -- str )
  221. here swap chars dup allot
  222.  
  223. ( c-addr str uc )
  224. >r tuck r>
  225. move 0 c,
  226. ;
  227.  
  228. \ get a pointer to the first character in 'str'. subsequent
  229. \ characters are at char+, etc. writing to the given character
  230. \ positions will change the contents of the string. use str.dup
  231. \ to get a private copy for adjusting.
  232. : str.chars ( str -- c-addr )
  233. ;
  234.  
  235. \ return the length of the string 'str' (may be expensive)
  236. : str.len ( str -- len )
  237. 0 swap
  238. begin
  239. dup c@
  240. while
  241. char+ swap 1+ swap
  242. repeat
  243. drop
  244. ;
  245.  
  246. \ create a new str object with contents duplicating 'str1' possibly at "here"
  247. : str.dup ( str1 -- str2 )
  248. \ dup str.chars swap str.len str.cpy
  249. here swap
  250. char-
  251. begin
  252. char+
  253. dup c@
  254. dup c,
  255. 0=
  256. until
  257. drop
  258. ;
  259.  
  260. \ create a new str object with the trailing characters of 'str1', having
  261. \ dropped the first 'u' characters in 'str1'. if 'u' is greater than
  262. \ the value str.len would return, the result may be garbage.
  263. : str.tail ( str1 u -- str2 ) chars + str.dup ;
  264.  
  265. \ create a new str object having the first 'u' characters in 'str1',
  266. \ possibly at "here". if 'u' is greater than the value str.len
  267. \ would return, the result may be garbage.
  268. : str.head ( str1 u -- str2 ) str.cpy ;
  269.  
  270. \ create a new str object that is the concatenation of 'str1' and
  271. \ 'str2'. if the sum of the lengths of the two input strings is
  272. \ greater than 255, the result may be garbage.
  273. : str.cat ( str1 str2 -- str3 )
  274. swap str.dup swap
  275. here char- \ assumes str.dup put it at "here" and left "here"
  276. \ pointing past the terminating nul
  277. over str.len chars dup allot
  278. char+ move
  279. ;
  280.  
  281. \ attempt to return the storage allocated for the given 'str' back to
  282. \ the system for use. no indication of success will be returned. if
  283. \ 'str' objects are passed to str.deallot in the reverse order from
  284. \ their generation via str.dup/str.cpy/str.head/str.tail/str.cat, and
  285. \ "here" has not moved via some other means, success is more likely.
  286. : str.deallot ( str -- )
  287. dup
  288. begin
  289. dup c@
  290. while
  291. char+
  292. repeat
  293. char+
  294. dup here = if
  295. - allot exit
  296. then
  297. 2drop
  298. ;
  299.  
  300. \ compare 'str1' and 'str2'
  301. : str.cmp ( str1 str2 -- -1|0|1 )
  302. begin
  303. over c@ over c@ dup
  304. while
  305. neqn if
  306. < 1 or nip nip exit
  307. then
  308. drop drop
  309. char+ swap char+ swap
  310. repeat
  311. drop
  312. nip
  313. nip
  314. 0<>
  315. 1 and
  316. ;
  317.  
  318. : str.= ( str1 str2 -- -1|0 ) str.cmp 0= ; \ are 'str1' and 'str2' equal?
  319. : str.< ( str1 str2 -- -1|0 ) str.cmp 0< ; \ is 'str1' less than 'str2'?
  320.  
  321. \ call xt ( c -- ) for each character, 'c', in the string
  322. : str.foreach ( xt str -- )
  323. swap >r
  324. begin
  325. dup c@ dup
  326. while
  327. swap r@ swap >r execute
  328. r> char+
  329. repeat
  330. 2drop
  331. r> drop
  332. ;
  333.  
  334. : str.emit ( str -- ) ['] emit swap str.foreach ;
  335. : str.c, ( str -- ) ['] c, swap str.foreach ;
  336. : str." ( "..." -- str ) [char] " parse str.cpy ;
  337.  
  338.  
  339.  
  340. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  341. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  342. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  343. \
  344. \ A list object is a singly-linked list of aligned addresses.
  345. \ Pointers to list elements, ple, have the following (very
  346. \ simple) format:
  347. \
  348. \ ple+0c: pNext \ the next entry in the list (or 0 for end of list)
  349. \
  350. \ Lists are most useful when data is stored at fixed offsets
  351. \ around this pointer, such as ple+1c or ple-1c, etc.
  352. \
  353. \ The base data in a list object is a single cell, which is
  354. \ simply a pointer to the first ple. This pointer may
  355. \ be null (0), indicating an empty list.
  356.  
  357. : list._ini ( pList -- ) 0 swap ! ; \ initialize a list, losing any previous data
  358. : list._del ( pple -- ) dup @ @ swap ! ; \ delete the next entry. dangerous if there is no next entry
  359. : list.push ( ple pList -- ) dup @ 2pick ! ! ; \ push an entry on the front of a list
  360. : list.pop ( pList -- ple ) dup @ if dup list._del then @ ; \ pop the first element off the list, if it isn't already empty
  361. : list.end ( pList -- ple ) begin dup @ while @ repeat ; \ find the last element in a list (may be expensive)
  362. : list.app ( ple pList -- ) list.end list.push ; \ add an entry to the back of a list (may be expensive)
  363. : list.next ( ple -- ple' ) @ ; \ next element in list
  364. : list.empty? ( pList -- -1|0 ) list.next 0= ; \ is the list empty?
  365.  
  366. \ count the length of the list (expensive)
  367. : list.length ( pList -- len )
  368. 0
  369. begin
  370. swap list.next dup
  371. while
  372. swap 1+
  373. repeat
  374. drop
  375. ;
  376.  
  377.  
  378. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  379. \
  380. \ Call xt ( ple -- -1|0 ) for each element in the list until
  381. \ non-zero is returned. Return either -1 or 0 indicating
  382. \ whether a non-zero was ever returned, along with the list
  383. \ entry *right*before* the one for which xt returned non-zero,
  384. \ or a pointer to the last element in the list.
  385. \
  386. : list.find ( xt pList -- pple -1 | pend 0 )
  387. swap >r
  388. begin
  389. dup list.next
  390. while
  391. >r
  392. 2r@ list.next swap execute if
  393. 2r> nip
  394. true
  395. exit
  396. then
  397. r> list.next
  398. repeat
  399. r> drop
  400. false
  401. ;
  402.  
  403.  
  404. \ Call xt ( ple -- ) for each element in the list.
  405. : list.foreach ( xt pList -- )
  406. swap >r
  407. begin
  408. list.next
  409. dup
  410. while
  411. >r
  412. 2r@ swap execute
  413. r>
  414. repeat
  415. drop
  416. r> drop
  417. ;
  418.  
  419.  
  420. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  421. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  422. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  423. \
  424. \ Unlike Python, this dict is purely a map from 'str'
  425. \ objects to 'pde's. The format for a pointer to a dict
  426. \ entry, 'pde' (an aligned address), is as follows:
  427. \
  428. \ pde+0c: pNext \ the next entry in the dict
  429. \ pde+1c: str \ the 'str' object with this entry's name
  430. \
  431. \ Typically, users will store data at pde-1c,
  432. \ pde-2c, etc., since the 'str' object may be variable length
  433. \ and tedious to get past, though this is not required.
  434. \
  435. \ The base data in a dict object is a single cell which is
  436. \ simply a pointer to the first pde. This pointer may be
  437. \ null (0), indicating an empty dict. Null also indicates
  438. \ the end of the list of entries.
  439. \
  440. \ The data format is generally compatible with the 'list'
  441. \ object format.
  442. \
  443. : dict._ini ( dict -- ) list._ini ;
  444. : dict.add ( pde dict -- ) list.push ;
  445. : dict.foreach ( xt dict -- ) list.foreach ;
  446. : pde.str ( pde -- str ) cell+ ;
  447.  
  448. \ Either find the 'str' in the given dict or return a
  449. \ pointer to the last entry in the dict. This routine uses
  450. \ global storage to save 'str', and so is neither re-entrant
  451. \ nor thread-safe. The entry returned is the one most
  452. \ recently added with either dict.add or dict.xadd
  453. variable _pName
  454. : _key_cmp pde.str _pName @ str.= ;
  455. : dict.find ( str dict -- ppde -1 | pend 0 )
  456. swap _pName ! ['] _key_cmp swap list.find
  457. ;
  458.  
  459.  
  460. \ "Exclusive add" the given entry to the 'dict'. The first
  461. \ matching entry is removed as with dict.del, and the new
  462. \ entry is either inserted at that position or put at the
  463. \ end of the 'dict' (if no previous entry was found). If
  464. \ a previous entry was removed, it's returned as 'orig'.
  465. \ Otherwise, 0 is returned.
  466. : dict.xadd ( pde dict -- orig | 0 )
  467. over pde.str swap dict.find
  468. drop dup list.next >r
  469. dup list.pop drop
  470. list.push
  471. r>
  472. ;
  473.  
  474. \ Remove an entry named by the given 'str', if found.
  475. \ Return the removed entry, 'orig', or 0, if none was
  476. \ found.
  477. : dict.del ( str dict -- orig | 0 )
  478. dict.find
  479. drop dup
  480. list.pop
  481. list.next
  482. ;
  483.  
  484.  
  485. 0 [IF] \ unfinished:
  486. : ??? ." unimplemented" abort ;
  487.  
  488. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  489. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  490. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  491. \
  492. \ The 'string' object stores a sequence of characters. It
  493. \ is much like the 'str' object, except that it is guaranteed
  494. \ to be able to store INT_MAX characters, if there's enough
  495. \ system memory, and null characters are allowed.
  496. \
  497. : string.new ( -- string ) ??? ; \ make an empty array of characters
  498. : string.zeros ( u -- string ) ??? ; \ make an array of 'u' characters initialized to 0
  499. : string.cpy ( c-addr u -- string ) ??? ; \ copy u characters from addr into an "array-of-characters" object
  500. : string.data ( string -- c-addr ) ??? ; \ obtain a pointer to the first character
  501. : string.size ( string -- size ) ??? ; \ get number of characters in string.data
  502. : string.resize ( size string -- string' ) ??? ; \ resize the array of characters
  503. : string.dup ( string -- string' ) ??? ; \ duplicate the array of characters
  504. : string.cmp ( string1 string2 -- -1|0|1 ) ??? ; \ compare two arrays of characters
  505. : string.cat ( string1 string2 -- string3 ) ??? ; \ concatenate two arrays of characters
  506. : string.delete ( string -- ) ??? ; \ destroy the array and release the memory used
  507. : string.foreach ( xt string -- ) ??? ; \ call xt ( c -- ) for each character in the string
  508. : string.emit ( string -- ) ['] emit swap string.foreach ;
  509.  
  510. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  511. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  512. \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  513. \
  514. \ The 'array' object stores a sequence of cells. It
  515. \ is much like the 'string' object, except that it works
  516. \ on cells, not characters.
  517. \
  518. : array.new ( -- array ) ??? ; \ make an empty array of cells
  519. : array.zeros ( u -- array ) ??? ; \ make an array of 'u' cells initialized to 0
  520. : array.cpy ( a-addr u -- array ) ??? ; \ copy u cells from addr into an "array-of-cells" object
  521. : array.data ( array -- a-addr ) ??? ; \ obtain a pointer to the first cell
  522. : array.index ( idx array -- a-addr ) ??? ; \ obtain a pointer to cell 'idx' of the data
  523. : array.size ( array -- size ) ??? ; \ get number of cells in array.data
  524. : array.resize ( size array -- array' ) ??? ; \ resize the array of cells
  525. : array.dup ( array -- array' ) ??? ; \ duplicate the array of cells
  526. : array.cmp ( array1 array2 -- -1|0|1 ) ??? ; \ compare two arrays of cells
  527. : array.cat ( array1 array2 -- array3 ) ??? ; \ concatenate two arrays of cells
  528. : array.delete ( array -- ) ??? ; \ destroy the array and release the memory used
  529. : array.foreach ( xt array -- ) ??? ; \ call xt ( x -- ) for each cell in the array
  530.  
  531. [THEN]
  532.  
  533.  
Advertisement
Add Comment
Please, Sign In to add comment