Main Page/RED By Topics: Difference between revisions

From Programming in RED
Content added Content deleted
Line 73: Line 73:




{| class="wikitable"
{| class="wikitable sortable"
|-
|-
!Command !! Purpose !! Input !! Output !! Modify Series !! Modify Series Index !! Record !! Index to Head !! Index to Current Pos || Other]
!Command !! Type !! Purpose !! Input !! Output !! Modify Series !! Modify Series Index !! Record !! Index to Head !! Index to Current Pos || Other
|-
|-
| Alter || || || || || || || || ||
| Alter || MODIFY || || || || || || || || ||
|-
|-
| Append || || || || || || || || ||
| Append || MODIFY || || || || || || || || ||
|-
|-
| At || || || || || || || || Yes ||
| At || IDX || || || || || || || || Yes ||
|-
|-
| Back || || || || || || || || ||
| Back || IDX || || || || || || || || ||
|-
|-
| Change || Changes series from current position || Series to change || YES || || || || || ||
| Change || MODIFY || Changes series from current position || Series to change || YES || || || || || ||
|-
|-
| Clear || Deletes everything from current position to tail || || || || || || || ||
| Clear || MODIFY || Deletes everything from current position to tail || || || || || || || ||
|-
|-
| Collect || || || || || || || || ||
| Collect || || || || || || || || || ||
|-
|-
| Compose || || || || || || || || ||
| Compose || || || || || || || || || ||
|-
|-
| Copy || Returns a copy of the series || || || || || || || ||
| Copy || GET-SET || Returns a copy of the series || || || || || || || ||
|-
|-
| Empty? || || || || || || || || ||
| Empty? || INFO || || || || || || || || ||
|-
|-
| Exclude || Returns first arguments values minus second argument values || || || || || || || ||
| Exclude || UNIONS || Returns first arguments values minus second argument values || || || || || || || ||
|-
|-
| Extract || || || || || || || || ||
| Extract || GET || Get elements. Cold also see block as record of elements || || || || || || || ||
|-
|-
| Find || Returns a series from the mathing position || || || || || || || ||
| Find || IDX || Returns a series from the mathing position || || || || || || || ||
|-
|-
| Head || || || || || || || || ||
| Head ||IDX || || || || || || || || ||
|-
|-
| Head? || || || || || || || || ||
| Head? || IDX || || || || || || || || ||
|-
|-
| Index? || || || || || || || || ||
| Index? || IDX|| || || || || || || || ||
|-
|-
| Insert || Insert a value in the current position shifting the previous value(s) to the right || || || || || || || ||
| Insert || MODIFY || Insert a value in the current position shifting the previous value(s) to the right || || || || || || || ||
|-
|-
| Last || || || || || || || || ||
| Last ||IDX || || || || || || || || ||
|-
|-
| Length? || || || || || || || || ||
| Length? || INFO || || || || || || || || ||
|-
|-
| Move || Move element(s) of the series to another || || || || || || || ||
| Move || MODIFY || Move element(s) of the series to another || || || || || || || ||
|-
|-
| Next || || || || || || || || ||
| Next ||IDX || || || || || || || || ||
|-
|-
| Path! || || || || || || || || ||
| Path! || || || || || || || || || ||
|-
|-
| Path? || || || || || || || || ||
| Path? || || || || || || || || || ||
|-
|-
| Pick || Takes the N'th value || || || || || || || ||
| Pick || GET || Takes the N'th value || || || || || || || ||
|-
|-
| Poke || Sets the N th value || || || || || || || ||
| Poke || SET || Sets the N th value || || || || || || || ||
|-
|-
| Rejoin || || || || || || || || ||
| Rejoin || MODIFY || || || || || || || || ||
|-
|-
| Remove || Remove the first value of a series starting from current position || || || || || || || ||
| Remove || MODIFY || Remove the first value of a series starting from current position || || || || || || || ||
|-
|-
| Replace || Replace the found value with another one || || || || || || || ||
| Replace || MODIFY || Replace the found value with another one || || || || || || || ||
|-
|-
| Reverse || Reverse all the arguments of a series || || || || || || || ||
| Reverse || MODIFY || Reverse all the arguments of a series || || || || || || || ||
|-
|-
| Select || Selects (extract) the item next to the matched one || || || || || || || ||
| Select || GET-SET || Selects (extract) the item next to the matched one || || || || || || || ||
|-
|-
| Skip || Move index one or more position forward|| || || || || || || ||
| Skip ||IDX || Move index one or more position forward|| || || || || || || ||
|-
|-
| Sort || Sort the series || || || || || || || ||
| Sort || MODIFY || Sort the series || || || || || || || ||
|-
|-
| Swap || Swap the current elements of two series || || || || || || || ||
| Swap || MODIFY || Swap the current elements of two series || || || || || || || ||
|-
|-
| Tail || || || || || || || || ||
| Tail || IDX || || || || || || || || ||
|-
|-
| Tail? || || || || || || || || ||
| Tail? || INFO || || || || || || || || ||
|-
|-
| Take || || || || || || || || ||
| Take || MODIFY || || || || || || || || ||
|-
|-
| Take || Remove and returns on or more elements of a series || || || || || || || ||
| Take || || Remove and returns on or more elements of a series || || || || || || || ||
|-
|-
| Union || Returns the unique elements of two series || || || || || || || ||
| Union || || Returns the unique elements of two series || || || || || || || ||
|-
|-
| Unique || REturns the unique elements of a series || || || || || || || ||
| Unique || || REturns the unique elements of a series || || || || || || || ||
|-
|-
|First || || || || || || || || ||
|First || || || || || || || || || ||
|-
|-
|Second || || || || || || || || ||
|Second || || || || || || || || || ||
|-
|-
|Third || || || || || || || || ||
|Third || || || || || || || || || ||
|-
|-
|Fourth || || || || || || || || ||
|Fourth || || || || || || || || || ||
|-
|-
|Fifth || || || || || || || || ||
|Fifth || || || || || || || || || ||
|}
|}



Revision as of 14:30, 20 January 2019

Topics

Code is DATA/Data is CODE

Series/Blocks

Selecting

Select returns the value next to the matched key. It could search also for types

Simplest Select Syntax is

Select BLOCK/SERIES KEY

Example:


>> select [a b c d] 'b == c

Now, the third one will be a block

Select returns the element

>> a: [a b [1 2 3 4] d] == [a b [1 2 3 4] d]

>> select a 'b == [1 2 3 4]


SELECT is the short form of:

>> probe first next find a 'b [1 2 3 4] == [1 2 3 4]

which could also be written as

>> probe pick next find a 'b 1 == [1 2 3 4]


Finding >> probe next find a 'b [[1 2 3 4] d] == [[1 2 3 4] d]


>> a: [a b [1 2 3 4] d] 'b == b >> probe first next find a 'b [1 2 3 4] == [1 2 3 4] >> select [a b c d] 'b == c >> select a 'b == [1 2 3 4] >> a: [a b "c1234" d] == [a b "c1234" d] >> select a 'b == "c1234" >> find a 'b == [b "c1234" d]


(TODO: Clarify if it copies)

Table


Command Type Purpose Input Output Modify Series Modify Series Index Record Index to Head Index to Current Pos Other
Alter MODIFY
Append MODIFY
At IDX Yes
Back IDX
Change MODIFY Changes series from current position Series to change YES
Clear MODIFY Deletes everything from current position to tail
Collect
Compose
Copy GET-SET Returns a copy of the series
Empty? INFO
Exclude UNIONS Returns first arguments values minus second argument values
Extract GET Get elements. Cold also see block as record of elements
Find IDX Returns a series from the mathing position
Head IDX
Head? IDX
Index? IDX
Insert MODIFY Insert a value in the current position shifting the previous value(s) to the right
Last IDX
Length? INFO
Move MODIFY Move element(s) of the series to another
Next IDX
Path!
Path?
Pick GET Takes the N'th value
Poke SET Sets the N th value
Rejoin MODIFY
Remove MODIFY Remove the first value of a series starting from current position
Replace MODIFY Replace the found value with another one
Reverse MODIFY Reverse all the arguments of a series
Select GET-SET Selects (extract) the item next to the matched one
Skip IDX Move index one or more position forward
Sort MODIFY Sort the series
Swap MODIFY Swap the current elements of two series
Tail IDX
Tail? INFO
Take MODIFY
Take Remove and returns on or more elements of a series
Union Returns the unique elements of two series
Unique REturns the unique elements of a series
First
Second
Third
Fourth
Fifth


Findind

Finding a value in a series/block requires FIND It returns the block positioned at the match or (none?)

To obtain the numeric index/position you should use POS? Example: POS? FIND a 'b


Note the difference in the output between finding and selectin

When exploring RED this could led to a misunderstanding [1 2 3 4] = a block containing 1 2 3 4 1 2 3 4 = a block containing another block which contains 1 2 3 4


[1 2 3 4] the element in the third position, which is a block [[1 2 3 4] d] the original series starting at thrid position which contains the thrird and fourth element

to get again the whole block you shoud

head a (why not a: head a)

Contexts

VID

Databases

RED/Systems

Compiling

PATHS

NONE, TRUE, EMPTY, ETC.

Active words

Natural language

PARSE

DSL

RED Code INIT

EXTERNAL Libraries

CODE MORPHING

Code internal Structure

Datatypes