r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Dialects] Questions about how to create dialects

Fork
9-Jan-2010
[477]
What Rebol can do is solve the problem and then do a coup-de-grace, 
like upload the results to a web server or something crazy like that.
Steeve
9-Jan-2010
[478x2]
well,  do you play Golf or not ?
at least, make a birdy
Fork
9-Jan-2010
[480]
Just of the code kind...and given Tiger Woods latest publicity I 
think I'll steer clear for now of the real sport :)
Steeve
9-Jan-2010
[481]
is the return carriage counted as a char or not ?
Fork
9-Jan-2010
[482]
Not unless it's part of the program function (e.g. you use it in 
a multi-line character constant bounded by braces to get a carriage 
return in your target program)
Steeve
9-Jan-2010
[483]
so you could use returns to replace closing square brackets for example, 
saving more chars
Fork
9-Jan-2010
[484x2]
Sunanda: The idea of a minor modification to the challenge and seeing 
what that does to the program is a good one; I would do that with 
interview candidates who knew the "right" solution to a problem (due 
to studying or seeing it before)... just introduce some whimsical 
constraint they hadn't memorized...
I think the second commandment is my favorite: "Thou shalt not worship 
graven images."  :)
Henrik
9-Jan-2010
[486]
Could an offshoot of this be a method for thumb coding? I'd love 
an app for phones which allow you to write code solely with your 
thumb.
Fork
9-Jan-2010
[487x5]
I don't know that I'd propose this for anything other than code golf. 
 Its saving grace is that it doesn't screw up Rebol or its legal 
syntax for dialects, while making it quite competitive in such contests.
The fact that you can read and write it without assistive technology 
is good, but you'd certainly prefer to use the normal syntax.
I'd put as a challenge to the Rebol community to refine Rebmu (or 
a similar syntax) to the point where they can submit an answer to 
code golf challenges that demonstrates some awesome feature of Rebol 
while still being in striking distance of the "winning" answer.  
I thought that perhaps showing Rebol 3.0 extending the roman numeral 
system to support higher order numerals than 1000 through unicode 
characters for M with a bar over it, etc. would be a good one.
(refer to http://en.wikipedia.org/wiki/Roman_numerals#Symbols)
The punch line being the one Sunanda alludes to: Rebol can play this 
game as well as languages designed to play *only* this game, but 
that's just the tip of the iceberg.
Steeve
9-Jan-2010
[492]
btw, what is the sourc of the roman-num function you use "in clear"
Fork
9-Jan-2010
[493]
Stevee: Hm?  I don't know what you are referring to.  I wrote the 
roman numeral function from scratch, in a fairly naive way.
Steeve
9-Jan-2010
[494]
don't play dumb :-)
Fork
9-Jan-2010
[495]
Nope, not playing.  I didnt spend much time on the roman numeral 
function, it's incidental.  Those code golfers were tweaking, I was 
writing plain and simple code.  What do you mean "roman-num"?
Steeve
9-Jan-2010
[496]
actually i would like to see your example in plain rebol.
Fork
9-Jan-2010
[497x4]
; The following initial declarations are implicit
; k: 0
; j: 0 
; s: ""
 

; readin senses the type of the argument and fulfills that from input
readin-mu s
 
foreach c s [
    ; n is the current digit value
    n: select [
        i 1 v 5 x 10 l 50 c 100 d 500 m 1000
    ] to-word-mu c
 
    ; if previous digit value is zero
    ; capture current digit and continue
    ; inversion is like not but supports 0 as false
    if inversion-mu j [
        j: n continue
    ] 
 
    ; based on whether the previous digit value is 
    ; less than the current one, we decide what to 
    ; add to the total.  If we need subtract the 
    ; previous digit then we also carry over the
    ; current digit into the next addition
    k: k + either-lesser?-mu j n [also n - j n: 0] [j]
 
    ; save current digit as the previous digit
    ; (note that it is possibly zero)
    k: n
]
 
; if lingering previous value is not zero 
; it will be added here
k + j
I was contemplating the good and bad of a "mush" function, and I 
think I'm against it, because it undermines my point--namely that 
you should be able to write this code without assistance from a tool.
But I'm on the fence.  Commenting is too important, and if you can't 
comment code and have it not count against your golf score something 
is wrong.
The only "new" trick for me in writing the above was ALSO.  BrianH 
clued me into it this week when he used it adapting my proposal for 
correcting the object none leak: http://rebol.net/wiki/Talk:Scoping_in_Rebol
Steeve
9-Jan-2010
[501x2]
something wrong in your code (although i didn't test it)
k: k + ...
k: n

k always erased with n
Fork
9-Jan-2010
[503x6]
Stevee: good catch, the commented version is not in sync with the 
decompiled version (as I said, day 1 of this, lots of back and forth). 
 If you run unmush you get:
>> unmush/deep [rSfeCs[Nse[i1v5x10l50c100d500m1000]twCi~J[JnCN]Kk+elJn[alN-j 
N0]'jJn]pK+j]

== [r s fe c s [n: se [i 1 v 5 x 10 l 50 c 100 d 500 m 1000] tw c 
i ~ j [j: n cn] k: k + el j n [al n - j n: 0] 'j j: n] p k + j]
So there are some k's in the commented version that should be js. 
 So it is when you're trying to maintain a document in wordpress. 
 :(
Okay maybe just one k.  Reason is I reformed the spec so that n, 
j, k were default defined to 0 as integers and had a rewrite in the 
middle.
I also changed continue's shortcut from CO to CN because I wanted 
CO for compose.  Every time you change something it wrecks everything. 
 I know text files have their... um... way.  But I still want computers 
to step up to the plate and give every reference a UUID.  Someday...
Saw some posts to the Rebol list about Intentional Programming, I 
still have hopes.
Fork
13-Jan-2010
[509]
Rebmu now has a fledgling homepage/logo/rationale: http://hostilefork.com/rebmu/
Graham
13-Jan-2010
[510]
Basic had one letter variables
Fork
13-Jan-2010
[511x5]
Well, Rebmu has a set of starting definitions for one letter things. 
 So s starts out as the empty string, i starts out as IF.  You can 
redefine these things.
And of course, you can use multiple characters whenever you so wish, 
even using the full Rebol words for things.
I've had some internal debates on questions like whether LN should 
be LENGTH? or if I should make any Rebol identifier that ends in 
a ? also have a ? in it.  These are some tricky questions, but on 
that particular decision (for instance) I've decided that the ? in 
the name is something important to keep.
I'm also thinking that it's better to use three-letters for things 
rather than use letter combinations that don't make sense.  If you 
run out of things RE can be (RETURN, REJOIN, REPEND, etc.) then the 
answer is not to pick one and make it RZ for no reason... but to 
pick the least likely to use in code golf and go to three letters. 
 If this is a problem for any particular challenge they can just 
write (for instance) Rrej at the beginning of the code and then have 
a shorthand.
Of course to make that worth it you would have to use rej more than 
twice:  rejREJ = RrejRr :)
Reichart
13-Jan-2010
[516]
I recall a childrens book from England when I was a child where each 
of the cartoon children in the book spoke in mostly single letters, 
it was something like:

Boy - I C U 
Girl - I C U 2

Boy - R U  HP 
Girl - I M HP

Boy - U R A QT


It was a bit silly, but well made, and they had some MUCH BETTER 
tricks of this than I have given from memory.
Sunanda
13-Jan-2010
[517]
Never knew it as a kid's game, but the Two Ronnies spun it into a 
TV sketch:
http://www2.prestel.co.uk/cello/swedish.htm
Chris
4-Mar-2010
[518x4]
I'm rethinking the behaviour of my 'import dialect (library: http://bit.ly/rebimport
) when working with structured data. At it's simplest form, 'import 
filters a block of key-string pairs based on a supplied set of constraints: 
import [a "1"][a: integer! is more-than 0] == [a 1] ; or none if 
the constraints are not met


There are two nested forms I'd like to support: 1) a continuation 
of key-value blocks [a [b "1"]] and 2) a block of values [c ["b" 
"1" "foo"]]


The first could just be a recursive function or parse call. The second 
needs a little more thought - on the face of it, it could just verify 
the contents conform to a preset group: [ ["a" "b"] contains some 
of ["a" "b" "c"] ] (or any of), which'd be fine for validating web 
form input (eg. multi-select list), but would rule out, say, a JSON 
block containing objects (as key-value pairs).  I'm trying to figure 
out if this is overkill or a genuinely useful way of validating structured 
data...


Then there's ["1" "2" "3"] <- be nice to validate as [some integer!] 
or [some integer! | decimal!]. I don't want it to be overly complex, 
but it should at least be useful - anyone have any conventional cases 
for validating a block of strings?
I should clarify that this is mainly used for validating user input.
For example ["1" "20" "46"] might represent options where input requested 
integers between 1 and 50.  Successful validation would return [1 
20 46] whereas ["1" "foo"] would fail as foo is not an integer.
import [opts ["1" "20" "46"]][opts: block! [integer! is between 1 
50]]
Anton
27-May-2010
[522]
I'm doing a filtering dialect facing similar problems. 
Examples:

[msg-id] = [ 10 .. 50 ]  ; msg-id must be between 10 and 50.
[msg-id] = [ .. 50 ]  ; msg-id must be any number up to 50.
[msg-id] = [ 50 .. ] ; msg-id must be 50 or beyond.

[group] = [ "Dialects" ]  ; group name must be "Dialects"
[msg] = [ .. "import" .. ]  ; message text must contain "import"

[msg] = [ all [[ .. "import" .. ] [ .. "dialect" .. ] ] ]  ; message 
text must contain "import" AND also contain "dialect".

[user] = [any [ "Chris" "Anton" ] ]  ; user name must be any of "Chris" 
or "Anton"
Fork
18-Jun-2010
[523x4]
A "code golf" question on StackOverflow caught my attention yesterday, 
and especially the frustrating ability of perl to win these competitions 
with utterly disgusting code which is unmodifiable with the slightest 
change in spec motivated me to resurrect my rebol dialect for code 
golfing.
My goal is to write "obvious" code in the Rebmu dialect which defines 
primitives and has structure that makes the perl stuff look like 
the backwards garbage it is, and still beat them on character count.
Here in the connect-the-dots problem challenge, I use the Rebmu dialect 
to best the winning perl solution (at the moment) http://stackoverflow.com/questions/2527477/code-golf-connecting-the-dots/3066878#3066878
AltMe put a wacky thing in that link, I'll try again