Comments (17)
The point about mysterious
proxying EOF is a very, very good one - it makes absolutely sense that you should be able to iterate across an array (or read from STDIN
in a loop) and read empty strings, falses and zeros but still stop when you reach the end of the collection.
I'm starting to pull together issues for the next iteration of Rockstar, and this one is definitely one to include.
from rockstar.
Here's a possible solution for this issue:
- iterate thru the space-split segments
- split all segments into character arrays
- check the length of the character arrays, if it's greater than 0, then it's valid
X is " 0 23 "
split X with " "
Let i be 0
while i is less than X
let Y be X at i
build i up
split Y into Z
say "Y=" + Y + ", Z=" + Z
if Z is greater than 0
say "valid"
cast Y
(Y is numeric now)
'''
from rockstar.
Here's another possible solution: use the "with" keyword. Twice.
(Input contains the value to be tested)
Let Test be Input with 1
Let Test be Test with 1
After those lines, different values of Input will result in different values of Test:
Input Test
"" "11"
"0" "011"
0 2
mysterious "mysterious11"
...at which point it's fairly trivial to tell them apart by looking at the value of 'test'.
from rockstar.
@weshinsley True - and also, it makes mysterious
meaningless (if you follow me :) ). So it would be a useless feature - but why should we keep it?
Dylan once said he is not afraid of breaking changes - and we can provide a proper compiler for each version (once there's a breaking change, I will save a version of Rocky to support the old version).
So, old codes will be able to run on old versions. We only need to distinguish them.
from rockstar.
OK - I think I can skirt around the comparison issues (for now) with
listen to input
split input into pieces with " "
join pieces into newinput with " "
split newinput into newpieces with " "
but I might run into problems comparing the 0 with things later...
from rockstar.
And
6 3 47 94 2
with a leading space is tricky (although we know in this case the leading space is not a zero...)
from rockstar.
That's clever - I wouldn't have thought of the split Y into Z line...
from rockstar.
So... the crux of the matter for me is this... suppose you have 3 lines of input that goes:-
123
0
234
If you've coded in other languages, you might expect mysterious
to be a kind of proxy for eof
- like:
listen to my heart
while my heart isn't mysterious
whisper my heart
listen to my heart
which stops reading early, because the character/string "0"
turns out to be mysterious. It's a bit of a surprise, since "0"
is not something I think most coders would class as "undefined". (It has length after all...) I think the simplest working form might be:-
listen to my heart
split my heart into my pancreas
while my pancreas isn't mysterious
unite my pancreas into my spleen
shout my spleen
listen to my heart
split my heart into my pancreas
Or, to put it another way, is mysterious
isn't always the most practical way of determining mysterious-ness, when there are zeroes floating about. Instead, we want to...
mysteriousness takes victim
shatter victim into particles
if particles greater than 0
(victim isn't mysterious)
But this all feels a little bit clumsy, and I wonder if mysterious
slightly overplays its hand here?
from rockstar.
Great :-)
Related: To solve the AoC puzzle, I flattened my 5x5 grid of numbers into an array of 25 numbers, indexes 0..24 inclusive. I then wanted to have a lookup table - a sparse associative array that lets me ask: where (if at all) does this number occur in this array. The intention is that numbers not present return "mysterious", as no entry is found in my lookup.
So unless I work around it, I have a problem distinguishing between "mysterious" meaning undefined (the number is not in my 0..24 array at all), or that it is present at position zero.
As a suggestion on how it could improve in a reasonably backward-compatible way - what about an additional term "meaningless", meaning something that really is a null/undefined. Brief (but very deep) poetic support for this suggestion:-
Everything that's meaningless is mysterious
But not everything mysterious is meaningless
from rockstar.
One simple workaround is to have your array return 1-25 for items in your array (subtract 1 to get the actual position) and mysterious for anything not in the array.
from rockstar.
Yeah, and that's what I do, and the occasional build up and knock down doesn't hurt. There may be other times though where you'd want to distinguish between zero and missing more immediately.
from rockstar.
Actually, it's rather a bug. The Spec says:
<Mysterious> <op> Mysterious
=> Equal.
<Non-Mysterious> <op> Mysterious
=> Non equal.
0 is non-mysteriuos, so 0 must not be equal to mysterious.
Also, the tests do not comply with this rule (equality/mysterious.rock): mysterious is null
is expected to have true
as a result (there is no test with 0
comparison)
from rockstar.
All of these succeed at present (on the TRY IT page) :-
if "0" is mysterious
shout "0 in quotes is mysterious"
if 0 is mysterious
shout "0 without quotes is mysterious"
if "" is mysterious
shout "empty string is mysterious"
if empty is mysterious
shout "empty is mysterious"
if " " is mysterious
shout "space is mysterious"
from rockstar.
This also succeeds:-
if mysterious is mysterious
shout "mysterious is mysterious"
but this (which is genuinely undefined) locks up - that's probably a different issue.
if potato is mysterious
shout "where did that potato come from"
from rockstar.
@dylanbeattie To incorporate the EOF-as-mysterous feature, we need to clear the mystery around mysterious
. It makes no sense for this feature if we cannot decide whether it's EOF, or we read empty line, 0, "0" or " " for the input.
It will cause a breaking change, though. Maybe worth to think on versioning as well.
from rockstar.
My thought was that an additional meaningless
might allow mysterious
to stay as it is, avoiding any breakage... ALTHOUGH I suppose that will affect those who already have meaningless
in their lyrics, so... hmm...!
from rockstar.
Related Issues (20)
- Some recommendations for Conditional statements
- Add support for end-of-line comments using # so that shebangs (e.g. #!/usr/bin/rockstar) work HOT 3
- How to work with "slash" characters HOT 2
- Emoji Support
- rock & roll operations - stack or queue?
- Operator precedence
- How to read stdin from file or pipe input to rockstar program on command line in Satriani? HOT 3
- Can I get length of array as a value? HOT 2
- Rockstar code version handling
- "has" as alias for "is"
- codewithrockstar.com is down HOT 1
- Add rockstar to https://www.99-bottles-of-beer.net/ HOT 1
- Character -> Number based on Unicode code point
- nth-fibonacci example contains an error.
- Expand comments to support Chordii/ChordPro formats
- If only there was a "random number generator" feature.... HOT 1
- Define syntax of import paths
- `nothin'` as an alias for `nothing`
- Lock-free Zygohistomorphic Prepropomorphisms for 99-Bottles-Of-Beer-On-The-Wallβ’ solutions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rockstar.