throw/catch except in *very* rare cases, but I always look over my shoulder when I do. Macros fall into the same mental space for me.switch style on desltop OSs.call red -c -t Android and sync it.also breaks space/timeAlso is very weird. It's brilliant, and I hope to only ever use it in dire circumstances.system/console/eval-command for?system/console/eval-command {prin "e"}probe system/consoleOne shall write a program that compresses string "AAABBAAC" to its compressed form "3A2B2A1C".>> out: "" parse src [collect into out some [s: set char skip any char e: keep (rejoin [(length? s) - length? e char])]] == true >> out == "3A2B2A1C"
>> rejoin parse "AAABBAAC" [collect any [s: set a skip any a e: keep (offset? s e) keep (a)]] == "3A2B2A1C"
>> rejoin map-each/eval s split "AAABBAAC" :<> [[length? s s/1]] == "3A2B2A1C"
offset?, I knew there's a better solution!s: "AAABBAAC"
result: ""
count: 1
forall s [
either s/1 = s/2 [count: count + 1][append result rejoin [count s/1] count: 1]
]rejoin allocation, doing two separate appends. Won't matter for small strings of course.append append result count s/1red -r file.red and run the output--cli on the command line.closure?; @dockimbel's closure func
closure: func [vars spec body][
; Don't have to reuse 'spec name; just saves a word.
bind (body-of spec: func spec body) (context vars)
:spec
]slice mezzanines?pair! should be simple enoughslice: func [
s [series!]
range [pair!]
/step
n [integer!]
/local c start end
][
start: first range
end: second range
code: [copy/part at s start (end - start - 1)]
either step [
c: do code
trim/all extract c n
][
do code
]
]
str: "There once was a man from Nantucket"
blk: [a b c d e f g h]
slice str 7x14
slice/step str 7x14 2
slice/step str 7x35 3
slice/step blk 3x7 2extract already does steps//: make op! function [
"Pick an item or get a slice (copy) from series, or return modulo of a scalar"
data [series! number! money! char! pair! tuple! vector! time!]
offset [number! money! char! pair! tuple! vector! time!]
"Negative indexes are tail-relative in series"
][
unless series? data [return modulo data offset]
either integer? offset [
pick either offset >= 0 [data][tail data] offset
][
copy/part
skip either 0 <= i: offset/1 [data][tail data] i
skip either 0 < i: offset/2 [data][tail data] i
]
]split ?slices[a..b].s/3..s/7s/3 not pick s 3 that's why I'd like to have a notation here instead of slice s 3x7.s/3x7 if we had real slices.s/3..7?s/x..y..-containing words become invalid then...7 (undefined lower limit).~.make op! maybe tomorrow will have time to play a bit, your example gave me some curiosity @hiiamboris slice thoughts.select/insert of a couple of code blocks' character on the code which manages the registration form). We will start the advertising campaign next week. I could write some updates during its launch.lib/ structure is versioned like winsxs on Windows, so the binary won't find any libs. Simplest solution to run a binary thus according to SO was... install Steam and run the binary from it (tada!). I can't imagine how can one develop anything under this distribution and I felt it's probably more sadomaso than Arch.Dockerfile.do %easy-list-x01.r
spec: [
List of albums
Each album has
title
artist
"catalog number"
year
"record label"
]
easy-list/open specstyledir in another place will still display the old size and modification time, until I *read* this file from it's another place. git gets tricked by this too and thinks that file hasn't changed.add command. Maybe I'll just write a batch wrapper to read smth on add.make-range: function [a [integer!] b [integer!]][
collect [i: a - 1 until [keep i: i + 1 i = b]]
]
~: make op! :make-range>> 2 ~ 8 == [2 3 4 5 6 7 8] >> char-range: (to-integer #"a") ~ (to-integer #"r") == [97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114] >> foreach i char-range [prin to-char i] abcdefghijklmnopqr
rejoin #"a" thru #"r" == "abcdefghijklmnopqr"
now/weekdaytranslate-shell? it works for me for en:de, occasionally en:fr, but has like 99% timeout rate for most languagesTrue;False into *itself* in japanese lol>> file: read %overseas-trade-indexes-June-2021-quarter-provisional-csv.csv
== {Series_reference,Period,Data_value,STATUS,UNITS,MAGNTUDE,Subject,Group,Series_title_1,Series_title_2,Series_title_3,Series_titl...
>> dt [parse file [some [#"," | skip] end]]
== 0:00:01.073 ; R2
== 0:00:05.98222 ; Reddt [load-json %file]?expand all feature in the viewer, as that would be a massive amount of overhead for large files. parse, R/S, JSON fast lexer based on Red's), but if someone else wants to do that, we'll sponsor it. parse on data that large, e.g. parse <26M-string> [some skip], may take a full second or more. But R/S will scream through it. Then it's a matter of only using parse on small pieces, between markers, which will be instant to a user's eyes.skip/offset? vs at/pick/index?. One of the main reasons some devs prefer, and argue for, zero-based addressing is calculating offsets based on element sizes. This makes sense in lower level languages, and even some dialects perhaps (e.g. R/S), where you're mapping indexes to offsets, but it makes index accuracy suffer in the process.Reusable Software, where he talks about things in terms of Linnaean classification for data structures. e.g. in many langs, stack have push/pop, queues have enqueue/dequeue, etc., but all 1D data structures can use the same name for these operations. We know this in Red because of the series! datatype. You can still add more control when needed, but being able to use the same interface for many things means a lot less cognitive load.MaterialAlertDialogBuilder(context,
R.style.ThemeOverlay_MaterialComponents_MaterialAlertDialog_FullWidthButtons)
.setMessage(resources.getString(R.string.long_message))
.setNegativeButton(resources.getString(R.string.decline)) { dialog, which ->
// Respond to negative button press
}
.setPositiveButton(resources.getString(R.string.accept)) { dialog, which ->
// Respond to positive button press
}
.show()help, the historical goal has been "keep it short, because it's for console use and the content is in the code itself." There's no reason it can't be done with new approaches, but a fundamental issue has been the use of plain text files that don't require special tooling. That's great for many reasons, but limiting. What I hope we can do is find organizational systems for content (code, docs, tests, training, and more) that let us tie together long-lived content (e.g. plain text), with tools that make the whole richer. It sounds easy, and really shouldn't be that hard. funcology, and things like my dict-doc experiment.call with the new file name and it would open it. I say *possible* because it works fine for something like Notepad where every file is in a new instance, but you want something that just adds a new file tab to an existing session. It's a good note for @toomasv, as he's done a basic notepad, and we should support extensions and use cases like this.---EXTRACTORS: does []table-stylewill be ready.%dir-scripts.red, may be edited manually). Resize, change sizes of list and content-area by dragging on separator bar, change font size by ctrl-wheeling. Just thrown together, not much tested, be careful not to overwrite your files.Money datatype merging is one of this: you could see how adding a DT has is implemented.vocabulary: ["wordlang1" "wordlang2" ["translation1" "translation2"] ["translation1" "translation2"]]
foreach [languageA languageA translations1 translations2] vocabulary [ ... your code here ... ]
pos: find/skip vocabulary word 4; where 4 is the record size if not none? pos [translations: pick pos 2]
pos: find/skip next vocabulary word 4; where 4 is the record size if not none? pos [translations: pick pos 2] ;
next because find always work on the first column, so you need to resposition the record start on language2.map!?vocabulary: #(
"good" ["dobrý" "správný"]
"bad" ["špatný" "ošklivý"]
)hash! with known words and 2 blocks for translations and strings.[word-language1 word-language2] correspondance, and search either on lang1 column and get lang2 and vice versa..succ or .succ!. (The latter modifies the string) succ for R2, and used it a number of times. @hiiamboris sequential IDs are pretty useful.1337@dmail.ai address is [still available for $200 at DMail](https://dmail.ai/presale). Either no hackers paying attention or they wouldn't risk having such a simple address for spammers will surely target it ;)¯\_(ツ)_/¯5e0b7202-9e3c-4e97-974c-9451d2baa701R.red already exists.[%r.red %r (1).red %r (2).red].copy in the name, which helps there.r.red and r (1).red and then after uploading there will be 3 files [Yes][No]"[a A] [ab Ab aB AB] [abc Abc aBc abC ABc AbC abC ...]), renaming over time, content changes, and how you present it to humans on incompatible systems. (n) we also just make another tradeoff. Those would be valid names a user could use themselves, but now they can't because it conflicts with our convention and changes the meaning, conflating casing implicitly. That affects users on both systems.%r.txt. How does my *code* do that without a unique name? There are scenarios where you don't care. What you care about is the content. e.g. SQL can query for you and returns sets of results. But there is also, *always* something that makes it unique, whether it's a key or a position in a list. File systems just put a human face on it. i.e. the names we see are already tags, mapped to internal inode and MFT entries.load %r and not know which file it will get. The extension makes the names unique, and adds meaning. Here we *can* use tags in places of names, absolutely. All we have to do is say load/options files/tagged [%r "text" [loadable Red]] ... where options could be require-unique or all.Apple.company.txtand apple.fruite.txtApple.company.txtand apple.fruite.txteither [] [] ;-)diff I think[play "TrackName" play "Soccer"]
play could be 2 different functions. One which play a song, another which starts a videogame.print "whichever is my political view, I pray this war ends and people will stop dying". No copy and paste allowed. Parse is, itself, implemented as an FSM, correct? And while it isn't bug free, it's one of the most powerful elements in Red, complex, and quite robust. Are there other areas in Red that *could* have used an FSM as part of their core design, even if only to inform the implementation? I think so. Do we want to do that at a granular level all the way down? I don't think so, but that's from my experience of not having great FSM or other tools that make it easy and natural. If you started someone out that way, it might seem perfectly normal to them, and then we can see what produces better results.Yes. But we're mostly of a generation that flies by the seat of our pants; and largely gets away with it. We can say "I couldn't have written so much code or built so much if I had to stop and design things first." or "I'm doing exploratory development, so the design would just be wasted when I reach a point where something unforseen comes up." I know I'm guilty of that. Far more than I care to admit. And there *are* two sides to things, because a state machine isn't the right tool to help design a dialect...or is it? Again, we don't know. DiaGrammar was a first step down that path. But maybe, just maybe, design time would have paid for itself and then some.Ki's Life Story: An Unnatural Disaster that Made the World a Better Placenvcontainer.exe, which is associated with a windows service NVIDIA LocalSystem Container. I'm not sure what it actually does, except there are people complaining that it seems to be uploading tons of telemetry data. Anyway, disabled it, and the problem went away 🙄System SKU: LENOVO_MT_82KB_BU_idea_FM_V15 G2 ITL Processor: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz, 2419 Mhz, 4 Core(s), 8 Logical Processor(s) BIOS Version/Date: LENOVO GGCN49WW, 21/07/2022
table! type for Red.read/lines and then processing each line as CSV.split can do it. If you have to deal with other people's data, handling all the options natively makes it easy for everyone to get consistent results quickly. You may also remember that our CSV codec is quite flexible *because* it's used for many different types of data.The MySQL server information is as follows:
IP address: 172.16.4.49
Database name: ameridroid
Username: root
Password: dummy
Write a function in Rebol that takes information from the following form and inserts it into the MySQL "clients" table.
<!DOCTYPE html>
<html>
<head>
<title>Client Record Form</title>
</head>
<body>
<h1>Client Record Form</h1>
<form action="insert_client.php" method="post">
<label for="first_name">First Name:</label>
<input type="text" name="first_name" id="first_name" />
<br />
<label for="last_name">Last Name:</label>
<input type="text" name="last_name" id="last_name" />
<br />
<label for="company">Company:</label>
<input type="text" name="company" id="company" />
<br />
<label for="address1">Address 1:</label>
<input type="text" name="address1" id="address1" />
<br />
<label for="address2">Address 2:</label>
<input type="text" name="address2" id="address2" />
<br />
<label for="address3">Address 3:</label>
<input type="text" name="address3" id="address3" />
<br />
<label for="city">City:</label>
<input type="text" name="city" id="city" />
<br />
<label for="state">State:</label>
<input type="text" name="state" id="state" />
<br />
<label for="zip">Zip:</label>
<input type="text" name="zip" id="zip" />
<br />
<label for="country">Country:</label>
<input type="text" name="country" id="country" />
<br />
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" />
<br />
<label for="email">Email:</label>
<input type="text" name="email" id="email" />
<br />
<label for="type">Type:</label>
<input type="text" name="type" id="type" />
<br />
<label for="ref">Reference:</label>
<input type="text" name="ref" id="ref" />
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>REBOL [
Title: "Insert Client Record"
]
client-data: make object! [
first_name: none
last_name: none
company: none
address1: none
address2: none
address3: none
city: none
state: none
zip: none
country: none
phone: none
email: none
type: none
ref: none
]
insert-client: func [
first_name [string!]
last_name [string!]
company [string!]
address1 [string!]
address2 [string!]
address3 [string!]
city [string!]
state [string!]
zip [string!]
country [string!]
phone [string!]
email [string!]
type [string!]
ref [string!]
] [
client-data/first_name: first_name
client-data/last_name: last_name
client-data/company: company
client-data/address1: address1
client-data/address2: address2
client-data/address3: address3
client-data/city: city
client-data/state: state
client-data/zip: zip
client-data/country: country
client-data/phone: phone
client-data/email: email
client-data/type: type
client-data/ref: ref
insert-sql: rejoin [
"INSERT INTO clients (first_name, last_name, company, address1, address2, address3, city, state, zip, country, phone, email, type, ref) VALUES ("
"'" client-data/first_name "'" ","
"'" client-data/last_name "'" ","
"'" client-data/company "'" ","
"'" client-data/address1 "'" ","
"'" client-data/address2 "'" ","
"'" client-data/address3 "'" ","
"'" client-data/city "'" ","
"'" client-data/state "'" ","
"'" client-data/zip "'" ","
"'" client-data/country "'" ","
"'" client-data/phone "'" ","
"'" client-data/email "'" ","
"'" client-data/type "'" ","
"'" client-data/ref "'"
")"
]
connect: open/no-wait/user root/pass dummy/database ameridroid/host 172.16.4.49
insert: insert-sql
close connect
]Red is a next-gen programming language, strongly inspired by REBOL. Main features are:
Human-friendly syntax
Homoiconic (Red is its own meta-language and own data-format)
Functional, imperative, reactive and symbolic programming
Prototype-based object support
Multi-typing
Powerful pattern-matching Macros system
Rich set of built-in datatypes (50+)
Both statically and JIT-compiled(*) to native code
Cross-compilation done right
Produces executables of less than 1MB, with no dependencies
Concurrency and parallelism strong support (actors, parallel collections)(*)
Low-level system programming abilities through the built-in Red/System DSL
Powerful PEG parser DSL built-in
Fast, compacting Garbage Collector
Cross-platform native GUI system, with a UI layout DSL and drawing DSL
Bridging to the JVM
High-level scripting and REPL GUI and CLI consoles included
Visual Studio Code plugin, with many helpful features
Highly embeddable
Low memory footprint
Single-file (~1MB) contains whole toolchain, full standard library and REPL (**)
No install, no setup
Fun guaranteed!
Write a poem about the Red programming language.Red, a language so strong and bold, A powerful tool to have and hold. A human-friendly syntax so easy to learn, A powerful tool to help us discern. Homoiconic and multi-typed, A powerful tool to keep us hyped. Functional, imperative, reactive and symbolic, A powerful tool to make us dynamic. Prototype-based objects, a powerful tool, A language to make us feel so cool. Macros and datatypes, fifty and more, A powerful tool to help us explore. Statically and JIT-compiled, A powerful tool to keep us styled. Cross-compilation done right, A powerful tool to make us bright. Concurrency and parallelism, A powerful tool to make us zen. Low-level system programming, A powerful tool to make us sing. PEG parser, drawing DSL, A powerful tool to make us swell. Garbage collector, GUI system, A powerful tool to make us beam. Scripting, REPL, plugin and more, A powerful tool to make us soar. Embeddable, low memory, A powerful tool to make us glee. Red, a language so strong and bold, A powerful tool to have and hold.
A powerful tool to make us glee.What does Ray Kurzweil say about the AI Singularity?.pck file.This code creates a server-side program to manage a cafe-style computer service, where customers can log in and out of computers, and pay for their usage. The code includes functions to register new computers, monitor customer usage, record logins and logouts, filter results by hostname, and update the status of each computer. The code also includes an event handler to capture the close window event, which pops up a confirmation window to ask the user if they are sure they want to quit.REBOL []
align: func [
"Forms data into a specified number of columns with optional alignment"
data
length
/left
/right
/center
/len
][
if right [
return head copy/part tail insert/dup head form data " " length (length * -1)
]
if center [
data: head insert/dup head form data " " len: (length / 2)
data: head insert/dup tail data " " len
return copy/part at data ((length? data) / 2 - len + 1) length
]
return copy/part head insert/dup tail form data " " length length
]REBOL [] ; start of REBOL block
align: func [ ; define a function called "align"
"Forms data into a specified number of columns with optional alignment" ; comment
data ; argument: data
length ; argument: length
/left ; argument: left
/right ; argument: right
/center ; argument: center
/len ; argument: len
][ ; start of function body
if right [ ; if right is true
return head copy/part tail insert/dup head form data " " length (length * -1) ; return the data formatted to the right
]
if center [ ; if center is true
data: head insert/dup head form data " " len: (length / 2) ; insert spaces at the head of the data
data: head insert/dup tail data " " len ; insert spaces at the tail of the data
return copy/part at data ((length? data) / 2 - len + 1) length ; return the data formatted to the center
]
return copy/part head insert/dup tail form data " " length length ; return the data formatted to the left
] ; end of function body
; end of REBOL block;return the data formatted to the center because it isn't totally obvious what that line does.;return the data formatted to the center because it isn't totally obvious what that line does.request handling in Lest. Here's how to deal with a HTTP request in Lest:snippet ; or `page`, see Lest docs what's difference "Method: " request/method ; Lest can auto-detect if it's run inside Hub and in such case, it makes the HTTP request object available " Query: " request/data ; so it's easily accessible from Lest. It also convert the query (GET/POST/whatever) to Red datatypes hr ; just a separator request/* ; `*` is a special token that will emit whole `request` object. It's useful for debugging purposes
request get %cgi.lest [ ; `request` is the keyword for a form, `get` is a method used and `%cgi.lest` is the target file called
text "name" "value" ; `text` is the input type, with two args, name and value. This is just a basic example, nothing fancy.
]%index.lest and %cgi.lest with separate form and actor, or you can put everything into one file and take care of the logic with Lest's built-in if, either and other conditionals.