- ABORT
- ABORT"
- ABS
- ACCEPT
- ACTION-OF
- AGAIN
- ALIGN
- ALIGNED
- ALLOT
- AND
- BASE
- BEGIN
- BL
- BUFFER:
- [
- [CHAR]
- [COMPILE]
- [']
- CASE
- C,
- CELL+
- CELLS
- C@
- CHAR
- CHAR+
- CHARS
- COMPILE,
- CONSTANT
- COUNT
- CR
- CREATE
- C!
- :
- :NONAME
- ,
- C"
- DECIMAL
- DEFER
- DEFER@
- DEFER!
- DEPTH
- DO
- DOES>
- DROP
- DUP
- /
- /MOD
- .R
- .(
- ."
- ELSE
- EMIT
- ENDCASE
- ENDOF
- ENVIRONMENT?
- ERASE
- EVALUATE
- EXECUTE
- EXIT
- =
- FALSE
- FILL
- FIND
- FM/MOD
- @
- HERE
- HEX
- HOLD
- HOLDS
- I
- IF
- IMMEDIATE
- INVERT
- IS
- J
- KEY
- LEAVE
- LITERAL
- LOOP
- LSHIFT
- MARKER
- MAX
- MIN
- MOD
- MOVE
- M*
- -
- NEGATE
- NIP
- OF
- OR
- OVER
- 1-
- 1+
- PAD
- PARSE-NAME
- PARSE
- PICK
- POSTPONE
- +
- +LOOP
- +!
- QUIT
- RECURSE
- REFILL
- REPEAT
- RESTORE-INPUT
- R@
- ROLL
- ROT
- RSHIFT
- R>
- SAVE-INPUT
- SIGN
- SM/REM
- SOURCE-ID
- SOURCE
- SPACE
- SPACES
- STATE
- SWAP
- ;
- S\"
- S"
- S>D
- !
- THEN
- TO
- TRUE
- TUCK
- TYPE
- '
- *
- */
- */MOD
- 2DROP
- 2DUP
- 2/
- 2@
- 2OVER
- 2R@
- 2R>
- 2SWAP
- 2!
- 2*
- 2>R
- U.R
- UM/MOD
- UM*
- UNLOOP
- UNTIL
- UNUSED
- U.
- U<
- U>
- VALUE
- VARIABLE
- WHILE
- WITHIN
- WORD
- XOR
- 0=
- 0<
- 0>
- 0<>
- \
- .
- <
- >
- <>
- #>
- <#
- #
- #S
- (
- ?DO
- ?DUP
- >BODY
- >IN
- >NUMBER
- >R
6.2.2030 PICK CORE EXT
Remove u. Copy the xu to the top of the stack. An ambiguous condition exists if there are less than u+2 items on the stack before PICK is executed.
See:
Rationale:
ContributeContributions
ruv
[277] Example implementation for PICKSuggested reference implementation2023-02-10 21:51:27
: pick ( x0 i*x u.i -- x0 i*x x0 )
dup 0= if drop dup exit then swap >r 1- recurse r> swap
;
gethbo
[363] Clarification on what constitutes an ambiguous condition for this word.Request for clarification2024-09-19 14:31:15
The description for this word says: "...An ambiguous condition exists if there are less than u+2 items on the stack before PICK is executed"
In this example with 3 items on the stack: (x2 x1 x0 2 -- x2 x1 x0 x2)
This example worked in gforth - However u+2 = 4 and since 3 < 4 this is an ambiguous condition.
I might be missing something here but shouldn't this read : "An ambiguous condition exists if there are less than u+1 items on the stack before PICK is executed"
ruv
[414] Interpretation of the top input parameter of PICKComment2025-10-07 08:43:07
The word pick has the type ( x.0 u.cnt*x u.cnt -- x.0 u.cnt*x x.0 ).
The word roll has the type ( x.0 u.cnt*x u.cnt -- u.cnt*x x.0 ).
The discussed word poke has the type ( x.0 u.cnt*x x.1 u.cnt -- x.1 u.cnt*x ).
In my other comment I wrote that pick "interprets the underneath stack items as an array on which it operates", and then u.cnt is an index in this array.
A more fundamental interpretation is that the input parameter u.cnt (in pick, poke, roll) represents the number of stack items that need to be "skipped" to locate the target input parameter x.0 (that is copied, taken, or overwritten).
A consequence of this is that:
2pickmust have the type( xd.0 u.cnt*x u.cnt -- xd.0 u.cnt*x xd.0 );2pokemust have the type( xd.0 u.cnt*x xd.1 u.cnt -- xd.1 u.cnt*x );2rollmust have the type( xd.0 u.cnt*x u.cnt -- u.cnt*x xd.0 );
Rationale: the number of "skipped" stack items should not depend on the data type of the target parameter.
See also my other comment on ForthHub (2024-12-02) on this regard.