REBOL 3.0

Comments on: R3 Teaser: The world's smallest ls

Carl Sassenrath, CTO
REBOL Technologies
15-Mar-2007 2:50 GMT

Article #0066
Main page || Index || Prior Article [0065] || Next Article [0067] || 18 Comments || Send feedback

You type:

foreach file read %./ [
    printf [16 -8 " " 24 " " 6] get query file
]

You get:

CVS\                   0 13-Mar-2007/4:02:39.483  dir   
Debug\                 0 16-Mar-2007/2:42:15.31   dir   
main.dsp           12649 7-Mar-2007/0:44:39.12    file  
main.exe          249856 16-Mar-2007/2:48:53.968  file  
main.plg            6710 16-Mar-2007/2:48:33.453  file  
output.txt           404 16-Mar-2007/2:49:29.765  file  
rebol.dll         240128 16-Mar-2007/2:48:02      file  
Release\               0 16-Mar-2007/2:45:53.953  dir   
test.r              5524 10-Jan-2007/0:31:43.553  file

Magic.

PS: Did you notice the UTC? More on that later.

18 Comments

Comments:

Brian Tiffin
15-Mar-2007 23:43:47
Wow

Plus we are going to be able to drop all the zeropad functions and use printf [-11] now/date and printf [-8] now/time instead? That'll make a simple thing simpler.

Jeff M
16-Mar-2007 0:25:57
Very slick.

Please tell me we'll be able to do similar expressions for string compositions.

-pekr-
16-Mar-2007 2:31:56
Haaaa! Ha! 'printf magic for me, that is! :-) Thanks, I hate not having pad/left/right function. It would be nice, if printf could form decimals too, as there is nothig worse than trying to output to form even small 1 / 100 = 1E-2 ;-)
Goldevil
16-Mar-2007 3:48:34
Gretoossive ! (Shortcut for great, cool and impressive)
Henrik
16-Mar-2007 4:02:57
So pretty.

What does "get query file" do? In an R2 console, I get 'none for any file.

Anton Rolls
16-Mar-2007 4:51:10
Very nice.. :) (I would put the actual filenames in the right-most column, as they have the most variable length).
Gabriele
16-Mar-2007 5:45:30
Henrik: I guess it's similar to R2's:

>> get info? %rebol.exe
== [660992 6-Dec-2005/12:19:35+1:00 file]
sqlab
16-Mar-2007 7:57:09
Does your last sentence mean, you are now using UTC instead of LCT as default?
Volker
16-Mar-2007 10:53:46
Best embedding of printf i have seen :)
Maxim Olivier-Adlhoch
16-Mar-2007 11:41:18
I always hated printf...

now I don't have a reason to, wow!

I'm just wondering if your printf truncates or extends the lines. and if decimals can have a dot notation like:

[16 -8 " " 24.2 " " 6]

where the .2 remainder would mean align all decimals AT second position (following negative to indicate from start or end).

I'm also curious if/how? you handle centering columns...

and the killer question... does it RETURN the string or not? subject of much debate on print itself ;-)

Ingo
16-Mar-2007 12:31:48
And it would be nice to have formf, too. Which will _only_ return the string.
Brian Hawley
16-Mar-2007 12:42:41
Nice. But I second Maxim's comment: I would also like a version that just returns the formatted string - perhaps called FORMAT (an extended FORM). Decimal formatting would be nice too.
Sunanda
16-Mar-2007 13:15:14
> as there is nothing worse than trying > to output to form even small 1 / 100 = 1E-2

I can think of a great many medical problems worse than that :-)

As far as I recall, the .01 ==> 1E-2 is a RAMBOed issue that affects Windows implementations only.....But if RT can put a wrapper around whatever WinAPI native is causing that, several of us will be grateful.

Maxim Olivier-Adlhoch
16-Mar-2007 15:47:29
yes when displaying data a clean decimal value is essential.

(think of view fields as well, for example)

Rob Lancaster
17-Mar-2007 3:40:03
While not a comment on printf, but more on what the code is actually doing?

Has anyone seen (cough) the MS Powershell command Format-Table?

dir | format-table dir | select name, directory, lastaccesstime | format-table

Automatically sizes columns and truncates strings... I'm finding it incredibly useful and very easy to use....

Brian Tiffin
17-Mar-2007 14:39:55
Can you tell we rebheads are jonesing for a sprintf style native?
Gregg Irwin
17-Mar-2007 14:42
Cool demo for concisness (always good), but we need more details on the dialect (e.g. how to format numbers with separators in them).

The first thing that jumped out at me was the use of a negative number to--I'm guessing--right align the value. Just doesn't strike me as REBOLish.

WRT a FORMAT func, that should really feed to PRINT, rather than having PRINTF, otherwise, we will need WRITEF or SPRINTF, etc.?

If PRINTF is just there to make C folks happy, that's fine, but then let's have a better way to do it as well, that really fits REBOL. A nice FORMAT func, and look at how tbl, eqn, et al do their thing.

Brian Tiffin
17-Mar-2007 15:21:54

So, an R3 teaser.

Carl, you know we are all now salivating at the mouth waiting for the bell? Is the bell about to ring? Or do we just keep humming the 'wake me up...when September ends' tune? :)

Keep them coming.

Post a Comment:

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

Name:

Blog id:

R3-0066


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a 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.

REBOL 3.0
Updated 26-Apr-2024 - Edit - Copyright REBOL Technologies - REBOL.net