Comments on: Wanted: An Idiom Dictionary
REBOL Technologies

Comments on: Wanted: An Idiom Dictionary

Carl Sassenrath, CTO
REBOL Technologies
14-Jan-2005 19:28 GMT

Article #0101
Main page || Index || Prior Article [0100] || Next Article [0102] || 2 Comments || Send feedback

Wouldn't it be nice to have a REBOL idiom dictionary? In other words, a place where users could look up the common idioms of REBOL? We've talked about this before.

An idiom is a sequence of words (functions) that produces a commonly needed result. Most idioms are short and sweet like this what that removes the last element from a series (string, block, etc.):

remove back tail series

Other idioms are more involved like the third line of this example that pads an integer with leading zeros to produce a five digit result. (I use this one a lot for making file names.)

number: 12
out: form number
insert/dup out "0" 5 - length? out
print out

Many users do not realize that such idioms exist and that these idioms are the reason why functions like REMOVE-LAST are not part of the language. The idiom is easy.

An open idiom dictionary would be useful because it helps users find these common sequences. No guessing needed. I often hear new users tell me, "oh, that's how you do it, I did not think of that."

A Possible Solution?

If someone wants to write a CGI-based idiom dictionary, we can host it on for REBOL users to access. To start, it does not need to be anything fancy or polished. The main thing is that it must be trivial to add a useful idiom to the list. Perhaps it could start like the one-liner script from a few years back.

I know that wanted to allow idioms within the library. But, at last glance, I did not see any. I think for to successfully support idioms, there might need to be a streamlined submission process that has a special form that includes: summary of the idioms function (e.g. remove last value from a series), the idiom itself, and an optional description of how it works. It could also include an optional author name.

Anyway, until then, we can start collecting idioms from the community at large.



Steven White
15-Apr-2010 12:16:13
This is a perfect example of a perfect example.

Some time ago I posted a question on the REBOL mailing list about how to do something like adding leading zeros. The answer I got (which worked just fine) was to reverse the starting number, append the desired number of leading zeros, and then reverse the result again so the appended zeros were now leading zeros.

So there you have it: A way, but not THE way, or the "idiomatic" way, or the way a "native speaker" would say it.

30-Apr-2010 17:12:32
This is my way

>> n: 11 == 11

>> next form 10000 + n == "0011"

Post a Comment:

You can post a comment here. Keep it on-topic.


Blog id:



 Note: HTML tags allowed for: b i u li ol ul font p br pre tt blockquote

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

Updated 1-Jun-2023   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code