Main Page/RED By Topics: Difference between revisions

From Programming in RED
Content added Content deleted
mNo edit summary
mNo edit summary
Line 2: Line 2:
= Topics =
= Topics =


Code is DATA/Data is CODE
=== Code is DATA/Data is CODE ===




Line 68: Line 68:


(TODO: Clarify if it copies)
(TODO: Clarify if it copies)

Table



{| class="wikitable"
|-
!Command !! Purpose !! Input !! Output !! Modify Series !! Modify Series Index !! Record !! Index to Head !! Relative Index || Other]
|-
| Alter || || || || || || || || ||
|-
| Append || || || || || || || || ||
|-
| At || || || || || || || || ||
|-
| Back || || || || || || || || ||
|-
| Change || || || || || || || || ||
|-
| Clear || || || || || || || || ||
|-
| Collect || || || || || || || || ||
|-
| Compose || || || || || || || || ||
|-
| Copy || || || || || || || || ||
|-
| Empty? || || || || || || || || ||
|-
| Exclude || || || || || || || || ||
|-
| Extract || || || || || || || || ||
|-
| Find || || || || || || || || ||
|-
| Head || || || || || || || || ||
|-
| Head? || || || || || || || || ||
|-
| Index? || || || || || || || || ||
|-
| Insert || || || || || || || || ||
|-
| Last || || || || || || || || ||
|-
| Length? || || || || || || || || ||
|-
| Move || || || || || || || || ||
|-
| Next || || || || || || || || ||
|-
| Path! || || || || || || || || ||
|-
| Path? || || || || || || || || ||
|-
| Pick || || || || || || || || ||
|-
| Poke || || || || || || || || ||
|-
| Rejoin || || || || || || || || ||
|-
| Remove || || || || || || || || ||
|-
| Replace || || || || || || || || ||
|-
| Reverse || || || || || || || || ||
|-
| Select || || || || || || || || ||
|-
| Skip || || || || || || || || ||
|-
| Sort || || || || || || || || ||
|-
| Swap || || || || || || || || ||
|-
| Tail || || || || || || || || ||
|-
| Tail? || || || || || || || || ||
|-
| Take || || || || || || || || ||
|-
| Take || || || || || || || || ||
|-
| Union || || || || || || || || ||
|-
| Unique || || || || || || || || ||
|-
|First || || || || || || || || ||
|-
|Second || || || || || || || || ||
|-
|Third || || || || || || || || ||
|-
|Fourth || || || || || || || || ||
|-
|Fifth || || || || || || || || ||
|}



Findind
Findind
Line 116: Line 214:


DSL
DSL

RED Code INIT

EXTERNAL Libraries

CODE MORPHING

Code internal Structure

Datatypes

Revision as of 13:29, 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 Purpose Input Output Modify Series Modify Series Index Record Index to Head Relative Index Other]
Alter
Append
At
Back
Change
Clear
Collect
Compose
Copy
Empty?
Exclude
Extract
Find
Head
Head?
Index?
Insert
Last
Length?
Move
Next
Path!
Path?
Pick
Poke
Rejoin
Remove
Replace
Reverse
Select
Skip
Sort
Swap
Tail
Tail?
Take
Take
Union
Unique
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