Questions tagged [red]

The Red language is inspired by the interpreted language Rebol, but is compiled and hence has a wider range of application...from device drivers to high-level purposes. It is functional, imperative and symbolic, with prototype-based object support. Like LISP and Rebol, it is homoiconic and thus its own meta-language. It is both statically and JIT-compiled to native code, with strong support for concurrency and parallelism (actors, parallel collections).

Red is a paradigm-neutral homoiconic language.

Red has a low memory footprint, and has a low disk footprint (< 1MB). Red seeks to be a "full-stack" language whose methodology is independent of any other toolchain. It's goal is to compile that which can be known ahead of time, JIT-compile that which cannot, and embeds a small interpreter into its executables to handle constructions which are not amenable to any compilation.

As an intermediate language (IL) Red uses a C-like language called . Red/System's parser is reused from Red itself...and for which it has its own code generators. The Red executable is able to build Red/System files directly (*.reds) as well as Red files (*.red), and Red/System code may be embedded freely in Red code.

248 questions
0
votes
3 answers

How to modify each element of a block by "foreach" in red/rebol

I want to modify each element of a block by foreach. I tried like this but failed: >> a: [3 4 5 6] == [3 4 5 6] >> foreach i a [i + 1] == 7 >> a == [3 4 5 6] ;; block a is not changed. What I want is [4 5 6 7] Is there a better way to achieve it?
lyl
  • 293
  • 1
  • 8
0
votes
1 answer

Why does loop variable in repeat not work

Loop variable of repeat can be used in its block like this: >> b: func [x] [x + i] == func [x][x + i] >> repeat i 2 [print reduce append copy [b] [3]] 4 5 You can see that the variable "i" is used by the function "b". However,in the following…
lyl
  • 293
  • 1
  • 8
0
votes
1 answer

How to pass block with context to routine?

I am continue to learn Red/System. And now I am trying to understand how to pass word with context to function. Here is my code: Red [Note: "compile in release mode (-r flag)"] mycontext: context [ list: [] ] foo: routine [ blk /local…
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
0
votes
1 answer

A 'compiler' for list comprehension in Rebol

I want to compile this list comprehension: >> lc [reduce [x y] | x in [1 2 3] y in [4 5 6]] == [[1 4] [1 5] [1 6] [2 4] [2 5] [2 6] [3 4] [3 5] [3 6]] in: collect [ foreach x [1 2 3] [ foreach y [4 5 6] [ keep/only reduce [x…
noein
  • 411
  • 2
  • 10
0
votes
2 answers

What is the best way to save a hash! block in Rebol?

I am using Rebol2 and would like to persist a HASH! block. Currently I am converting it to-string then using save. Is there a better way? For example: r: make hash! ["one" "two"] I want to save this to a file, then load it back to r.
Atomica
  • 23
  • 6
0
votes
1 answer

Red to dotnet or java android: .Net -> Red (Not Implemented)

On https://github.com/red/red/tree/master/bridges it says not implemented, will it be ?
user310291
  • 36,946
  • 82
  • 271
  • 487
0
votes
1 answer

In Red, how do I search through a block for a string matching a pattern?

Given: player-wins: [ "rock breaks scissors" "paper covers rock" "scissors cut paper" ] I want a function which accepts two strings, each representing any of rock, paper or scissors and then returns the element that matches,…
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
0
votes
4 answers

How to increment element of block after found element?

Given player-choices: ["rock" 0 "paper" 0 "scissors" 0] How could I increment the value after "paper" in this block by searching for "paper"?
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
0
votes
4 answers

How to find the first element of a block of strings whose first character matches an input character?

Given weapons: ["rock" "scissors" "paper"] If I did player-choice: ask "(r)ock, (p)aper, (s)cissors or (q)uit? " how could i look for the character entered by the user in the block with word weapons attached to it
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
0
votes
2 answers

How did `find` actually locate a character in a string, when it was passed a string, not a character?

I was surprised to note that find "rspq" "q" actually found q in the series. The reason it surprised me is that the string "rpsq" is a series of characters and I expected to have to specify "q" as a character not as a string. This leads to 2…
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
0
votes
1 answer

How to convert a string to Date in red

If I accept a date from a user using ask and then wish to use it as a Date by using to-date, I get an error. >> to-date "31-Dec-2019" *** Script Error: cannot MAKE/TO date! from: "31-Dec-2019" *** Where: to *** Stack: to-date What is the correct…
rahul
  • 598
  • 1
  • 9
  • 20
0
votes
1 answer

Equivalent of Rebol effect [gradient] in Red?

I searched on Google but can't find any example in Red equivalent to this in Rebol: http://www.rebol.com/view/demos/gradient.r view layout [ style box box 64x64 across backdrop 0.50.0 vh1 "Gradient Examples" below guide box…
user310291
  • 36,946
  • 82
  • 271
  • 487
0
votes
1 answer

Red-lang Event: symetric of over (not-over)?

https://doc.red-lang.org/en/view.html over mouse Mouse cursor passing over a face. This event is produced once when the mouse enters the face and once when it exits. If flags facet contains all‑over flag, then all intermediary events are produced…
user310291
  • 36,946
  • 82
  • 271
  • 487
0
votes
0 answers

RED LANGUAGE : changing button image doesn't work

I tried to do this, but after clicking nothing happens: view [ button %head.jpg [ face/image: %tail.jpg ] ] Update: RED IS A LANGUAGE I PRECISE SINCE ASKED :)
user310291
  • 36,946
  • 82
  • 271
  • 487
0
votes
1 answer

Is there an option to fit image size within a button?

If %heads.jpg is big, in the case of button it won't resize: view [ image 140x140 %heads.jpg button 140x140 %heads.jpg ] Is there an option to fit image size within a button ?
user310291
  • 36,946
  • 82
  • 271
  • 487