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
[454x3]
I showed you my answer to get ['a b:] in a brief notation
>> unmush ['aB]
== ['a b:]
From 5 chars down to 3, and it's legal to the Rebol parser.
Steeve
9-Jan-2010
[457x2]
ok i understand, i just proposed to avthe burden caused by a safe 
alternance of letter's casing
avthe=avoid
Sunanda
9-Jan-2010
[459]
Following some thoughts of Christoph Budzinski back in December, 
I wrote a short article on an approach to REBOL code golf last month......It 
takes quite a different approach to yours. But as it was never published, 
your approach must have priority :)

What I suggested in the article was:


  1. we create a private group here to thrash out the principles and 
  practicesl then launch a set of REBOL code golf challenges


  2. current code golf is seriously flawed as it counts characters 
  not lexical elements:
        variable1: variable1 + variable2
       is much better  code than:
         v1: v1 + v2
       and should have the same golf score

3. in REBOL, the First Rule of Code Golf is:
       Parse always wins

  (this has been empirically observed over many REBOL code challenges)
Fork
9-Jan-2010
[460]
Well, I understand the concern, but I didn't do it just to be weird. 
 :)
Steeve
9-Jan-2010
[461]
only to save ":" what a tremendeous gain !!! :-)
Fork
9-Jan-2010
[462]
Stevee: But my point is you're forgetting the spaces, which are needed 
too, since colons cannot appear in words.
Steeve
9-Jan-2010
[463]
i agree for saving spaces
Fork
9-Jan-2010
[464x6]
Look at the Roman Numerals program [rSfeCs[Nse[i1v5x10l50c100d500m1000]twCi~J[JnCN]Kk+elJn[alN-j 
N0]'jJn]pK+j]
Then look at what it unmushes to:
[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]
Saves 40%.  The colons and the spaces are intertwined issues, just 
due to the rules of Rebol.  And I feel that if the dialect wasn't 
parseable Rebol but a string it wouldn't rightfully be called a Rebol 
dialect.
Sunanda: Rebol definitely could get some publicity with empathetic 
people if it were to embrace the code golfers...
Sunanda: I feel from my experience with parse that it's the sort 
of thing that can, if it fits your problem, help you a great deal... 
but it often seems to be just short of the needed functionality. 
 I feel if your task does not depend on knowing the true/false result 
of matching, then series operations are often better.  I've been 
thinking "if you don't use the boolean result of parse, you probably 
aren't working on a task that needs parse."
Steeve
9-Jan-2010
[470]
Generally Rebolers don"t make any difference with dialects parsing 
a string or a loaded block. It's called dialect as-well.
Sunanda
9-Jan-2010
[471]
My other main article point was:

  4. Real golf has 18 holes per round. Most code golf plays just one 
  hole. To be more realistic, there should be at least three holes 
  -- ie after the first hole's scores are published, the challenge 
  setter makes a modification to the challenge. Scores for that hole 
  are (somehow) equated to the amount of original code the survives.
Fork
9-Jan-2010
[472x3]
5. you do not bring your sony robot, night vision goggles, laser 
guidance systems, etc. onto the golf course.  You bring a bag of 
sticks and you use your own arm, eyes, and brain.
Obviously people who do code golf come to it from different perspectives, 
I think Rebol's key here is just to engage by giving lively and flexible 
solutions which pique interest.  I intentionally didn't clone the 
deranged "winner" of the roman numeral contest because he'd thrown 
out the program logic, it was no longer source code.  I can edit, 
debug, and insert probe messages into mine easily.
>> rebmu [rSfeCs[Nse[i1v5x10l50c100d500m1000]twC (probe n) i~J[JnCN]Kk+elJn[alN-j 
N0]'jJn]pK+j] 
Input String: XIV
10
1
5
14
Steeve
9-Jan-2010
[475]
REBIRDY would be a better suitable name for your dialect ;-)
Fork
9-Jan-2010
[476x2]
I think of it as "rebol mooshed" or "rebol microscopic" or "rebol 
please unask this development method" :)
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
[503]
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: