« first day (2253 days earlier)      last day (2604 days later) » 

5:00 PM
@ГригорийПерельман hint: ? followed by a character is a string literal
 
@MartinEnder Would that be equivalent to... !":!!":"!"?
 
no, it's equivalent to !":" ? !"!" : "!"
 
Oh... ? must cause some awfully weird parsing scenarios
 
not to mention it can be at the end of a function
 
How does Ruby know when you use ? as ternary and when to use it as a character literal.
 
5:01 PM
so a.b?3:4 is invalid
@ГригорийПерельман if ? is followed by whitespace, then its a ternary, otherwise, it a char literal
 
@ConorO'Brien That's kinda like 123.toFixed() in JS is invalid, I guess
 
@ETHproductions yeah, identifiers can end in ? or ! as well and : is also used for symbols
 
IMHO languages should have as few multiple-ways-to-parse instances as possible (zero preferably)
 
So you can do foobar.string? to check if foobar is a string. Functions also don't need parentheses to call them.
I remember now
 
5:04 PM
Yeah, I know a little Ruby as well
 
> Now, this doesn't deserve a WAT. It's just a sign of how awesome Ruby is. Now, if you ever actually do this ... WAT.
 
Well I guess the second ? there does come after a character literal, forcing it to be a ternary since the other two options wouldn't be valid
 
irb(main):017:0> ??.string?
NoMethodError: undefined method `string?' for "?":String
 
5:05 PM
??.what?
 
irb(main):001:0> ??.is_a? String
=> true
 
Oh, .string? doesn't exist on anything?
 
@ETHproductions you could add it
 
But, if you do... WAT
 
5:06 PM
I like that you can change the behavior of operators in Ruby glares at JS
 
I could have sworn it was a thing tho...
 
There's a nil?
 
nil is special.
 
That wouldn't work in JS, if you try to get a property of null it just throws an error
 
5:07 PM
for loops are weird in Ruby
 
Don't use for loops in Ruby
 
list.each |x| {
    # do stuff
}
 
@Cyoce yes
 
@ГригорийПерельман that's wrong... it would be:
 
@ГригорийПерельман list.each do |x|; end
 
5:08 PM
@ГригорийПерельман did you mean each?
 
@ConorO'Brien Ooh, just found a good test case for a JS parser I'm attempting to create
 
list.each { |x|
  # do stuff
}
 
5:08 PM
@ETHproductions oo fun!
 
For loops are stupid.
 
Ruby likes iterables
 
I like loop.with_index do |_, i| ... end
 
Or there's list.each.each.each.each.each.each.each do |x|; end
 
It might just be me doing it wrong, but { ... } only seems to work with for-each loops and not any other kind of construct.
 
5:10 PM
@TuxCopter now, if you ever actually do that... wat
@ГригорийПерельман you can pass a block to any method
 
@JanDvorak Um... loop?
 
@ГригорийПерельман it should work with any that requires a block
 
I can't seem to get it to work with if, it just doesn't want to.
 
@Cyoce yep. It just calls its passed block forever, or returns an enumerator to do that
 
@ГригорийПерельман if isn't a function
 
5:12 PM
@ГригорийПерельман it's called a block. You can pass a block to any method, and your methods can implement it by calling yield to invoke the block, or saving it to a parameter by putting an additional parameter with an &in front of the name
 
with_index is a method that modifies an enumerator
 
Is do ... end a kind of "block" literal?
 
    def thing_with_block
      yield
    end

    def other_thing_with_block(&block)
      block.call
    end
 
@ГригорийПерельман yep
 
5:13 PM
g2g, battery dead
 
o/
@Cyoce What does yield do?
 
@ГригорийПерельман it calls the passed block
 
@ГригорийПерельман it calls the block passed to the method yield is in if you don't want to save the passed block as a parameter
 
@ETHproductions do you have a github link for this?
 
The two examples I gave do the same thing.
 
5:14 PM
No, I just started writing it in a Notepad++ document last night
 
And what does &block do? Why isn't is just block? I have so many questions
 
nice, can't wait :)
 
I'm working on the tokenizer ATM. Numeric literals are hard
 
@ГригорийПерельман the & indicates that it's a block parameter, not a normal one.
 
So, ruby doesn't care about types, except for blocks and nonblocks.
 
5:15 PM
@ETHproductions how so?
 
No. Blocks just have special syntax.
 
Actually, now that I think about it, I started this parser thingy as the first step in creating a tool that looks for potential golfs in JS code-golf entries
 
Blocks aren't a type, it's a syntax construct
 
If you wanted to, you could just pass a proc as a normal parameter. That's what &blocks get converted to.
 
5:16 PM
@ETHproductions funny, I was thinking about making a parser of my own to make an auto-JS obfuscator. Not too different, haha
 
@ConorO'Brien There's 123 and 123.456, and then there's 0x123 which doesn't ever have a decimal point, etc.
Maybe I'm just overthinking it
 
yeah
you should just parse all possibly valid number sequences then check them later
 
Can you do special things like 1.f in JS?
 
Oh, and there's numbers with a leading decimal point as well (.123)
@ГригорийПерельман Nope, that throws a SyntaxError. Not sure what you're trying to do there though
1.f throws an error, 0x1.f returns the f property of 0x1
 
In Java, 1.f specifies that it's a float and not a double.
 
5:20 PM
Ah. JS doesn't have anything like that, other than 0b, 0o, and 0x for binary, octal, and hex literals
 
You can do 1f, 1d, 1l
 
JS also only has one generic Number type
 
number  = "0" + ("x" | "b" | "o") + DIGIT_SEQUENCE
number |= DIGIT_SEQUENCE
number |= DIGIT_SEQUENCE + "." + [DIGIT_SEQUENCE]
number |= "." + DIGIT_SEQUENCE
using some sort of pseudo parser language
 
heh, I'm just coding it from scratch in JS
 
oh, nice
 
5:21 PM
I don't know any parsing tools
 
Java has 0b101 and 0xf42 but also just plain old 042 for octal.
@ETHproductions So is all division float division?
 
Right
JS also has 042 octal literals as well
 
If I were you, I'd have some sort of needle function, where needle("str") returns true if, from the current parsing index, the next characters are s then t then r. If you're not adverse to using regex, you could integrate regex into this needle function. Tho I have no idea how you're rolling this
 
@ETHproductions Which is a bit weird considering it has typed arrays.
 
I should probably write a helper function to strip the first match of a regex off of the current code and return it (e.g. code = "1+2", f(/\d+/) == "1", code == "+2")
@ConorO'Brien Just some looping and some regex
 
5:24 PM
Hai
Oh wait I already posted
 
@Dennis Well, those were added long, long after JS was first designed...
 
Are you making a JS linter or something?
 
@ETHproductions I think I have written a function that does that, one sec
 
@ГригорийПерельман Yes, exactly. A JS linter whose style is "make the code as short as possible". That's a perfect way to put it
It doesn't make the changes for you, just alerts you where changes could be made
 
@ETHproductions I know. But why not add the numeric types as well?
 
5:26 PM
This is true...
 
If its for golf you probably just don't need to support octal and binary.
 
it's better to support the general case
 
I was going to use the babylon-parsed tree, but a) those are a little too complex for me to work with right now, and b) I wanted to try making my own parser
 
Shout out if you were already working on this, (or if you think it's a good challenge) and I might undelete it.
 
// returns [removed, code] if match succeeded, false otherwise
const stripReg = (code) => (regex) => {
    if(code.search(regex) === 0){
        let [mat] = code.match(regex) || [];
        return [mat, code.slice(mat.length)];
    } else {
        return false;
    }
}

let code = "1+2";
let r = stripReg(code);
let p;
[p, code] = r(/\d+/);  // ["1", "+2"]
@ETHproductions found it
 
5:30 PM
Oh cool, that might strip out a lot of the ifs I'm using
 
@ConorO'Brien, wow! You're absolutely terrible at golfing!
 
@StewieGriffin it's not for golfing >_>
 
Oh, it won't strip out the ifs, it just means I can use one regex per token instead of three
 
@ETHproductions oh quick note this doesn't work
 
Um, ok, what doesn't work about it?
 
5:32 PM
the curried function saves the original string instead of using the modified string
make it non-curried and it should work
 
ok, cool
Maybe I'll just declare it inside the loop so it can directly modify the code variable and I'll only need to input the regex
 
@StewieGriffin Why did you delete it in the first place?
 
you get a cookie if you can figure out what this does without running it
 
is this C?
 
yes
i wrote it :D
 
5:36 PM
@betseg Runs on TIO, hits cache.
 
@betseg ...it makes my brain hurt
 
@Dennis easier to run on tio than compiling and running on my pc
 
Whoa... is _ an addition function using only bitwise operators?
 
:D
 
@ETHproductions yes, also a ternary operator
 
5:38 PM
Well yes, but no arithmetic
 
@Dennis The immediate downvote, followed by a feeling that there might be more coming...
 
@ETHproductions a?b:c; == if(a != 0) { b; } else { c; }
 
I am aware of what a ternary operator does :P
 
I can reopen it though, if you (and/or someone else) think it might be a good challenge...
 
I just can't believe I figured out what that small part does without running it
 
5:40 PM
@StewieGriffin link?
 
@betseg hm, let me just consult the table of bitwise operators that I've memorized...
 
12 mins ago, by Stewie Griffin
Shout out if you were already working on this, (or if you think it's a good challenge) and I might undelete it.
 
@StewieGriffin Ultimately your call, but I don't think you should a post because of a single downvote.
 
IMO it's not a fun challenge to decipher, because it mainly relies on recursion and bitwise operators
 
...and __ is multiplication without arithmetic operators, right?
 
5:41 PM
@ETHproductions ;_; yep
Have a piece of cookie
 
Now I'm stuck at [ 0 ...4], I'm not familiar with whatever that C syntax is
 
@StewieGriffin For those of us who can't see that deleted post, what was the general idea behind it?
 
@MistahFiggins Undeleted it. Hopefully someone will enjoy it :)
 
@ETHproductions Basically all the elements between 0 and 4 i.e. from _8[0] to _8[4]. It's a GCC extension IIRC, can be rewritten as [0 ... 4]
 
Got it. That's what I thought after reading the surrounding code
 
5:44 PM
0
Q: Lists and arrays, part by part

Stewie GriffinIn this challenge, you'll get four different but somewhat related tasks that must be solved in a specific manner. First, I'll explain the tasks, then follows an explanation of how you must solve it. Your code should for all four tasks take two positive integers as input: n,m, where n<m. All task...

 
I'm learning quite a bit of C today :P
Ah-ha! It prints the chars of {100+4,100+1,100+8,100+8,100+11}, that is, hello
That was fun :)
You should have used _(_8[_0],_7[_0++]) at the end though :P
 
Oh I forgot :p
 
And _0=_(_0,1<<0)
 
@betseg ok, I think I got it. I had to think a while on _. Darn bitwise operators. From there it was easy
still so much fun :D
 
@ETHproductions The language I'm working on is precisely this.
 
5:50 PM
@AdmBorkBork hype is it just in design phase, or have you started writing it? is there a github?
 
Still in design, no github or anything yet.
 
@ETHproductions 🍪
 
A really good C minifier or optimizer or something might be able to golf that program down
@betseg :D
 
do I at least get compensation cookie for expanding code? lol
 
A register and a double-ended stack (i.e., you can "pop" from either the top or the bottom). Operators manipulate the register and the appropriate "top" of the stack, then store the result back in the register.
 
5:52 PM
@ETHproductions lemme try with gcc -O3
 
@AdmBorkBork this sounds like glorified assembly code haha
 
I also plan on having an operator that is something like "Parse the rest of this line as PowerShell, passing the entire stack as the $args arguments"
 
@ConorO'Brien Shoot, how will I parse template literals?
With the nested ${}s and all
 
nope even -O3 doesnt optimize the _ function to add
 
@ETHproductions recursively? e.g., have a parseLiteral function, then for each ${ encountered, just call that function
 
5:54 PM
@ConorO'Brien The items on the stack aren't individual digits. You could "push" an array and it would be one element on the stack, for example.
 
oh, that's cool
long live stack-based languages!
 
Oh damn it. I got the reciprocal almost sorted out, except for the case of zero point something.
 
@ConorO'Brien [0...4] gives an error btw, GCC says there are too many decimal points
 
oh, forgot a space
 
CMC: Print 'cat' (with any variation of capitals) in 32 or less bytes of brainfuck
@Riker
 
o-o
 
@ConorO'Brien 🍪
 
10/10 thanks
 
Just barely met the byte requirement...
 
@Riker Oh wow, I almost didn't recognize you with your new avatar
 
6:06 PM
lol
not for too long but I like it atm
 
woah that wasnt someone else i though that was someone else
 
lol
yeah, I'm not sure imma keep it
mainly because I use avatars to recognize people and I don't want to annoy anybody
 
Change the colours to be in this order: red, green \n blue, yellow
then you become windows cat
 
no.
windows causes global warming
or at least house warming
 
but they also allow one to see clearly
 
6:09 PM
And they leak heat in the winter
 
0
Q: Using Recursion to Solve Addition Problems

kengchiThis is a homework question which I have no idea how to start, hoping for some pointers. Suppose I have a pair of integers represented in the form of ABBAC + BAC = ACCCD, where each alphabet represents an integer from 0 - 9, write a recursive code which computes the number of integer solutions ...

 
already closed
 
@NewMainPosts You had one job...
 
How do I politely say "SO won't do your homework for you either m8"
 
6:11 PM
You don't.
 
let them learn the hard way?
 
*sigh* did either of you two even read the be nice meta post
 
My bounty on codegolf.stackexchange.com/questions/114219/… has finally paid for itself in upvotes, but no one's answering ;-;
@ConorO'Brien Yes, which is why I haven't commented on the question yet.
 
I guess the question could actually make for a good PPCG question
 
6:13 PM
@ConorO'Brien But that defeats the purpose of tokenizing...
 
@ГригорийПерельман relevant
 
It's still March tho... foo.
 
@ГригорийПерельман :P
tbh it is april 1st in some countries atm
 
I had to deal with nested strings in Japt. Took me about 50 hours over the course of a year and a half to get it just right
 
Ik
@ETHproductions Nested strings? You mean backslash escaped or some other way?
 
6:15 PM
@ETHproductions how so? It's the only sane way to deal with it that I can tell
 
@ГригорийПерельман Like template literals in JS: (`a${`b${`c`}d`}e`)
 
btw, I did steal that from reddit @ГригорийПерельман
and the top comment is gold
> Did I need to watch Will Arnett narrate a microwaved burrito? No, but it was amazing.
 
@Riker I'm in Greece :(
 
Should I know who Will Arnett is?
 
And I'm not in the mood to enable VPNs and such.
 
6:16 PM
@ГригорийПерельман nah
@EriktheOutgolfer :/
 
@ConorO'Brien Yes... I don't think it's possible to tokenize in such a way that allows for nested strings
:'(
 
define nested string?
iirc tokenize module supports that
but that's python
 
1 min ago, by ETHproductions
@ГригорийПерельман Like template literals in JS: (`a${`b${`c`}d`}e`)
 
ah
 
UUuuuu .NET balancing groups
 
6:17 PM
in stacked, I don't like the way I do it, but it works. I account for characters in strings, and work with depth, but it's blergh
 
@ГригорийПерельман ikr, they are so weird and amazing
 
@ConorO'Brien That's what I do in Japt as well. I think that's really the only way
 
is JS open source?
we could try taking a peek there
 
Makes me wonder how template strings were one of the first ES6 features to be implemented, since they break most conventional parsing methods
 
I don't think it's FOSS
 
6:19 PM
@ConorO'Brien I think the V8 engine is, not sure though
 
@ConorO'Brien JS isn't one thing AFAIK, browsers have different variations.
 
right, so any implementation would be ok
@ETHproductions oh, fun, into the rabbit hole.
 
@ConorO'Brien FireFox is open source, you can check in there.
 
> Google Chrome, the open source browser from Google
 
6:20 PM
I thought chrome was proprietary
 
Chrome is closed source, Chromium is OSS
 
@ГригорийПерельман ye
 
Yeah, it's Chromium. Chrome has proprietary stuff in it, so you can't really consider it 100% OSS.
 
6:21 PM
This file has several mentions of template literals, not sure if it's useful though
 
What's v8 licensed under?
oic it's BSD
 
@ГригорийПерельман woah, have you seen this? en.reddit.com/r/place
 
@Riker can i place only 1 square? i dont want to waste :P
 
I can't figure out how to place it >:U
or maybe I accidentally did already
 
@ETHproductions you know, I don't feel so bad about variable names anymore. DCHECK(next_next_.token == Token::UNINITIALIZED);
 
6:29 PM
 
was just about to link that
 
@betseg oh every 5 min
 
ah
 
@ConorO'Brien Why do their variables all have trailing underscores :P
 
that explains it, I was wondering how people drew those things
 
6:32 PM
-1
Q: Ghost in the shell

AaronIn honor to the 1995 classic ghost in the shell (of which I'm going to see the remake tonight) I propose a challenge where you create a shell with a ghost in it. The challenge: Create a REPL shell that evaluates numerical statements and has a chance of returning the wrong numerical answer betwe...

 
@ETHproductions I have no idea, it's starting to tick me off lol
heyy we should see how narcissus does it
 
narcissus?
 
from a quick search through the source code, it appears that it just doesn't
not yet, anyway
 
> Latest commit by dherman about 5 years ago
Probably not gonna happen either
 
6:41 PM
true
 
Well, I guess that means that I'll have to be the first to do it in JS
(jk, I'm sure it's been done before in other linters/minifiers/etc.)
the heck, how did I switch rooms there
 
@MendeleevLemon I just saw Matthew. I asked him if he installed Gentoo yet, he threw a pencil at me and referred to what happened as "Creepy as fuck" and "How the hell did you know I was there"
2
 
in real life? well obviously, I suppose
 
Do you three live near each other, I guess?
 
Same county, but it would be completely impractical for me to be able to get to Lemon's house.
 
6:52 PM
Matthew?
 
Lemon's dad gives Matthew private lessons in Physics
16 hours ago, by MendeleevLemon
user image
@Dennis Just a guy I know, he's not on PPCG.
 
invite him
 
@ГригорийПерельман oh, I thought you meant SIGSEGV
 
I didn't even realize that's who SIGSEGV was
 
6:54 PM
@KritixiLithos heh, I did too
 
MatthewOverflow
 
user165474
@ГригорийПерельман Which lemon?
 
@ГригорийПерельман Pavel is sooo evil. How could a mortal install that mess?
 
@HyperNeutrino the Mendeleev one
 
user165474
Okay. Thanks.
 
user165474
6:56 PM
Oh wait maybe I should have checked who wrote the original message ;_;
 
user165474
Also is SIGSEGV (not the user) a segmentation-fault or is it something else?
 
@ГригорийПерельман :D
 
@HyperNeutrino Signal: Segmentation Violation
 
user165474
Oh okay, thanks.
 
user165474
So when is the signal raised? I think it's when something tries to access a forbidden section of memory but I'm not sure.
 
6:59 PM
Is Place the Reddit april fools thing?
I was hoping for a reprise of Robin
 

« first day (2253 days earlier)      last day (2604 days later) »