« first day (744 days earlier)      last day (4220 days later) » 

user142019
2:00 AM
Can anyone verify if this is correct so that we don’t have to repeat it every time?
 
17.6.4.3 in the standard.
 
Xeo
@Zoidberg'-- No idea about C, but C++ seems correct.
 
gist.io has weird CSS
 
Xeo
Note that we have an SO question on that.
 
user142019
@Xeo the C part is correct, I’m sure of it.
 
2:01 AM
"std::array<T, N> is defined to be exactly equal to T[N]" -- That's trivial. The discussion at hand wasn't trivial one dimensional arrays. The discussion was about multi-dimensional arrays, which std::array can't handle except as ragged arrays. Big difference.
 
@Zoidberg'-- The rules apply to names, not identifier.
 
Xeo
182
Q: What are the rules about using an underscore in a C++ identifier?

Roger LipscombeIt's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, you'll probably use "m_foo". I've also seen "myFoo" occasionally. C# (or possibly just .NET) se...

 
user142019
@Xeo much better. :P
 
user142019
Why are the rules so complex?
 
@Zoidberg'-- Actually the C rules apply to identifiers, C++ rules to names.
 
user142019
2:03 AM
Why not just say: starts with double underscore = reserved, anything else = not reserved.
 
user142019
Would be much better.
 
Save yourself the trouble, don't use leading underscore? xD
 
user142019
Ritchie must have been smoking a lot when he designed C.
 
@Xeo - std::array<std::array<T, M>, N> is a ragged array. Accessing the [i][j] element involves going through two pointers. T[M][N] is a contiguous array. Accessing the [i][j] element involves but one indirection.
 
user142019
Two pointers?
 
2:04 AM
Could be that the standards differ too much and that the C++ concepts of names and identifiers don't map very well to the whatever C concepts are used.
 
user142019
@DavidHammen How are there any pointers?
 
Xeo
@DavidHammen o_o
 
user142019
There are no pointers with std::array.
 
user142019
And arrays are not pointers.
 
user142019
And std::array never decays to a pointer.
 
2:05 AM
@DavidHammen It's not ragged. Indirections are the same. You're thinking of std::vector<std::vector<T>>.
 
user142019
@DavidHammen Do you know how std::array is implemented?
 
user142019
template<class T, std::size_t N>
class array {
public:
    /* ctors, operators and decent interface here */

    T __elems[N];
};
 
It can't be private, std::array<T, N> is an aggregate.
 
user142019
So the memory layout is exactly the same no matter what.
 
Xeo
The standard even has T elems[N]; in the class array overview.
with a comment that the name is only for exposition
 
2:08 AM
Well there are other descriptions with 'exposition-only' details, you should not take them at face value.
It's enough that array specializations must be aggregates and that std::array<int, 3> a = { 1, 2, 3 }; be required to 'just' work to leave very little to the imagination, barring compiler magic. The exposition-only detail isn't even necessary.
 
user142019
2:22 AM
What is Pentecost about? Wikipedia is being cryptic for an atheist like me.
 
I have a friend that unhelpfully suggests that whichever Christian holiday is currently coming up is all about "the Virgin Mary ascending to Heaven". Of course he's right at some point in the year (I think), but not the rest of the time...
 
user142019
Mary being a virgin is bullshit.
 
An omnipotent entity is involved, why do you care?
 
user142019
Mary is the mother of Jesus. God is the father of Jesus. Mary is the mother of God. So Mary fucked her son, God, to breed Jesus.
 
user142019
Weirdness is weird.
 
user142019
2:27 AM
And God made the first humans, so he existed before his mother, Mary.
 
user142019
Which makes even less sense.
 
user142019
Not to mention that Joseph (IIRC) is also the father of Jesus.
 
I'm pretty sure at least one of those is wrong
 
user142019
I think they are all wrong.
 
user142019
Mary cannot possibly be a virgin since there was no IVF two thousand years ago.
 
user142019
2:28 AM
Or she must have gotten pregnant from swallowing or something.
 
@Xeo Do you mind that slice<>(t) is not the equivalent to Python's t[:]? Needs to be e.g. slice<Foo>(t) where Foo is one of FromTo, From, To, Stride.
 
0
Q: How to implement a method return something like Object-in-Java in C++

Anh TuanI'm learning C++ from a Java background and here is a problem I just met: Let's say I have a class named A. I use a wrapper called AWrapper. I want A has a link to its wrapper, not just AWrapper but any wrapper. So in Java, I can implement this as below: public class A { Object tag; Obj...

hm
 
Whoo Java.
 
user142019
Who the fuck calls his class “Object”.
 
user142019
That’s fucking ambiguous. It could be anything.
 
2:41 AM
It should be called "Class" not "Object"
 
Someone who comes from Java
 
user142019
Java is a cancer.
 
I just spent 2 hours with this kid I was talking about earlier about how does he use strings.
Turns out he uses strings as "string str = "Hello World"; but was confused because mine had an std prefix in it.
 
So he didn't know what a namespace was?
 
No.
1 hour ago, by Rapptz
> Nope, I don't know arrays. I don't even know what anything that starts with std:: means.
 
user142019
2:44 AM
@Pubby It is a terrible question anyway. It is completely unclear what he wants.
 
I should have figured it out by then but eh. Me == Annoyed
 
He wants circular dependencies :)
 
user142019
Circular dependencies are bad and he should feel bad.
 
user142019
Java and PHP are terrible inventions. I really wish their inventors all scary diseases and slow and painful deaths. From deep within my heart.
 
Xeo
@LucDanton What would slice<>(t) do?
 
2:50 AM
@Borgleader check out shift
 
@Xeo It's the empty case for slice<Indices...>(t).
 
Xeo
So it'd return an empty tuple?
 
Yes.
 
@Cheersandhth.-Alf Yeah I ended up finding a piece of code that stores all params in a variable except the first one.
 
Xeo
@LucDanton Hm, dunno. It kinda makes sense if you think "slice<> == slice nothing", but you can also think "slice<> == don't slice something out (and return the full thing)"
 
2:54 AM
What a bad time to go on /b/
 
Xeo
I think the empty case wouldn't need a special case to implement right now, eh?
@Rapptz Why?
 
Someone reposted those images of the chick cutting her stomach open with a knife and poking around with it.
In the same thread there's someone sticking gauge needles on his penis.
 
@Xeo Oh ya it's already functional.
 
Xeo
But the other semantics would just require a full specialization that returns t
 
user142019
@Rapptz what? Bad time? /b/ has about the best gore you can get.
 
user142019
2:56 AM
And they have some fetish threads right now. But I’m not into those things. :/
 
user142019
/b/ is awesome, regardless.
 
I'd link to the thread but I'd rather not.
 
@Xeo No everything is functional. But if you want a full slice you need to spell out e.g. slice<From<>>.
 
bad bad bad.
 
Xeo
@LucDanton That reads kinda weird.
 
2:59 AM
Pick whichever you like most: slice<Stride<>>, slice<To<>>, slice<From<>>, slice<FromTo<>>.
 
slice<To<>> is my vote
 
Okay, I need a real mod, not just for [-n, n) to add support to ranges.
@Rapptz No I mean use whichever you want. They all work the same.
 
Xeo
using All = From<>;
 
@LucDanton Ah.
 
slice<Across>?
slice<Colon>, to reflect on [:]!
 
Xeo
3:01 AM
The whole idea to invoke slice and not slice anything is kinda strange, tbh
0
A: How to implement a method return something like Object-in-Java in C++

Dave DoknjasI think all you need is a void pointer - this compiles, but I haven't played around with it: class A { public: void *tag; virtual void *getTag() { return tag; } virtual void setTag(void *tag) { this->tag = tag; } }; class AWrapper { public: A ...

I like how this guy actually mapped the code 1:1 from Java
Everything's virtual and even the member assignment in the ctor.
 
@Xeo foo[:] = bar has different semantics than foo = bar, I think.
Not so much in C++ with its value semantics, perhaps?
 
Xeo
btw, does python have something similar to [1..4] in Haskell?
 
@Xeo This is horrendous.
 
user142019
Yeash I got a 1 GET.
 
@Xeo [i]range?
 
user142019
3:04 AM
@Xeo range(1, 5) is similar.
 
Semantics-wise at least. Nothing on the syntax level.
 
Xeo
>>> s = range(5)
>>> s
range(0, 5)
 
user142019
Xeo do
 
Xeo
Something that makes s print [0,1,2,3,4]? :P
 
user142019
map(lambda x: x, range(1, 5)) :P
 
user142019
3:05 AM
Or list(range(1, 5)).
 
Xeo
ah, list works
Kinda verbose, though
 
lol verbose coming from C++
 
Xeo
@LucDanton From testing, there doesn't seem to be much difference, except that foo = bar lets you change the variable type
@Rapptz Shush, you. I really like Haskell's [0..5] :/
 
@Xeo I expect the former to be a deep assignment and the latter to be a shallow assignment (i.e. rebinding).
 
user142019
Everything is verbose compared to Haskell.
 
Xeo
3:09 AM
@LucDanton makes sense
 
Scala isn't so verbose, even though it's a strongly typed language.
 
Xeo
@Borgleader Haskell is also strongly typed
And even statically typed
 
@Xeo Didn't say otherwise
 
user142019
Haskell doesn’t do any implicit type conversions whatsoever.
 
@Xeo Yes, confirmed. l = [0, 1, 2]; alias = l; l[:] = l[::-1]; l == alias ends with True. Try changing the last assignment.
 
Xeo
3:10 AM
@Zoidberg'-- Well, it also has type inference literally everywhere. Can you even assign a concrete type to a parameter?
 
user142019
@Xeo yeah you can do this:
 
user142019
map (+ (1 :: Float)) [1..10]
 
Xeo
That assigns to an argument
I meant parameter
 
user142019
Or with {-# LANGUAGE OverloadedStrings #-} the following is also handy in some cases: "foo" :: ByteString.
 
user142019
@Xeo ohh a parameter.
 
user142019
3:11 AM
You mean this?
 
a :: Int
a = 42
 
user142019
foo :: String -> String
foo s = s ++ "Hello"
 
user142019
s must be of type String.
 
Xeo
Oh, ok
 
user142019
And it’s considered best practice to do this.
 
Xeo
3:12 AM
Right, I forgot for a sec that Haskell forces casing on the first letter for types and functions
 
user142019
@Xeo Except if function names don’t start with a letter.
 
user142019
_Foo is a fine function name, even though the first letter is a capital letter.
 
Xeo
aye
 
user142019
But that was just my pedantry. :P
 
@Xeo :: forces having a type on the right-hand side anyway.
 
user142019
3:14 AM
:: is also required when using read (in most cases, or always?).
 
user142019
foo = map (\s -> read s :: Integer) ["42", "1337"]
-- otherwise the compiler won’t know the resulting type
 
No, that's fine. But you'll hit the monomorphism restriction pretty quick.
read :: String -> Int
 
user142019
Of course you can also do foo = map (read) ["42", "1337"] :: [Integer] instead, which is less ugly (no lambda needed).
 
user142019
@LucDanton read :: String -> Double also exists. And read :: String -> Integer.
 
No I meant that the lambda is not required at all.
 
user142019
3:17 AM
Depends on the context.
 
There's only one context up there.
 
user142019
foo :: [String] -> [Integer] -- indeed, lambda not needed
foo = map read
 
Xeo
Thinking about it, Haskell's type inference must be pretty complicated.
 
foo = map (read :: String -> int) ["42"]
You suck.
 
user142019
ohh yeah. :P
 
user142019
3:19 AM
Of course.
 
user142019
I’m tired, okay? :P
 
user142019
@LucDanton or, you know.
 
user142019
foo = [42]
 
Xeo
lol
 
Depends on locale.
 
user142019
3:21 AM
ugh lolwat
 
user142019
even for integers?
 
I have no idea, I just said that.
 
user142019
[42] is a singleton, by the way. People told me singletons are bad.
 
@Xeo A bit late to the party but... ideone.com/sXki4H Scala classes can be define without much code.
 
user142019
 
Xeo
3:27 AM
@Borgleader I guess object Widget is something like a module (name)?
 
user142019
Don’t even think about it.
 
@Xeo No. In Scala Objects are singletons, they serve as a container for what you'd normally tag as static (methods, and class members). They're called companion objects. In this case I used it to store the main method.
 
Xeo
@Borgleader Ah, okay.
 
The cool thing is in a lot of cases the compiler can infer the types of the variables so you dont always have to write it
(as seen in val a = ...)
 
Xeo
Btw, to make the code compile I had to rewrite it to object Main
I think modern languages just have to have type inference.
 
3:32 AM
On ideone?
 
Xeo
Yeah
 
user142019
I think ancient languages also just have to have type inference.
 
I don't see a run button :S
 
Xeo
@Borgleader You tick "run code" when you write the code
Right below the language list
 
user142019
:S it the wrong smiley. You’re looking for (\/)(;,,;)(\/).
 
Xeo
3:32 AM
@Zoidberg'-- Right, but chances are high they don't.
 
Oh right from there, I thought there might have been another way
 
user142019
There is no reason C couldn’t have type inference.
 
@Zoidberg'-- Id' say there are about 120 of them (at least if memory serves, the last time I checked, that was about how many people were on the C committee anyway).
 
user142019
Function returns int —> variable is int.
 
@Xeo Also I should point out. I forgot to erase the println(a) line. It does nothing.
 
3:36 AM
@Xeo Mmh, those FromTo aliases aren't as convenient to reuse for ranges as I thought they would be. The mechanisms that replace the defaults with sensible values are template aliases, not very compatible with e.g. the size of a range.
Bah, doesn't matter. I will extend the interface of FromTo & friends and leave the work of replacing defaults for ranges to range::slice, as a new mechanism. Doesn't count as duplication as the tuples need their compile-time mechanism.
And From<0>::To<12> is convenient for clients and already refactored. That counts as a win-win-win.
@Xeo Do you expect support for more than random-access ranges?
 
Xeo
@LucDanton Why not support everything Boost.Range supports?
Oh, boost::adaptors::sliced requires random-access
that's kinda surprising.
@LucDanton I don't know about that. Ranges usually require runtime arguments
 
Mmh, my complaint was that if I wanted helpful diagnostics those would require more works.
But I might as well rewrite Boost.Range if I want to support a fully-featured slice.
 
3:52 AM
Joss Whedon is awesome.
 
@Xeo On the other hand I can write a slice_iterator and be done with it.
 
Xeo
@LucDanton Rewriting a whole library for just one feature, eh?
 
Hey it's a big feature. I'm not even done with it for tuple and tuple-like types.
In fact I'd better take a break from all that.
 
Damn, I'm up against Jon Skeet! — Etienne de Martel May 29 '11 at 16:05
lol. Was casually browsing through your history
 
4:11 AM
Hi, guys. how much is a 1T portable hard disk in USA?
Any one know it?
 
@Pubby thank you.
 
That $85 Toshiba USB 3 one looks good
 
yeah
 
4:45 AM
Can't convert literal type to type in the general case, sadface. More boilerplate!
 
Why does gdb suck
 
while (condition) {} . What happens is the condition is a number ?
 
Monkeys jump out of it.
 
@georgemano What kind of number?
 
a variable
 
user406009
4:51 AM
@georgemano In C/C++ everything that is not 0 is true. Zeros are false.
 
user406009
A rather stupid system.
 
@Lalaland thanks!
 
@georgemano Erm. That's not what I meant. Integer or floating point?
@Lalaland It comes from C, which did not have a boolean type, so ints were used instead.
 
Floating points aren't numbers, they are abominations.
 
user406009
@EtiennedeMartel has a good point, floating point might act differently.
 
4:53 AM
@StackedCrooked Don't be such a Cat.
 
Doesn't change much. bool(number) has the same effect as number != 0.
 
The only thing that changes is comparisons automatically promote floats to doubles, iirc.
 
I actually don't know if that works for complex numbers. My implementation accepts it FWIW.
 
Do you sometimes use !!foo()?
As in if (!!some_c_call_that_should_return_zero()) { throw some_error(); } // else continue program ...
 
Yup, works for complex types as well.
 
5:00 AM
Well, a complex number would be false if the real part if zero, and true otherwise, right?
 
number != 0, always.
So yes, but it's not special-cased or anything.
 
user406009
What about NaN?
 
@Lalaland NaN is never equal to anything, so I guess it would be true.
 
How do you get a NaN in C++?
 
user406009
Guess not.
 
user406009
 
user406009
Seems that NaN is true.
 
user406009
It really does seem like our floating point system is chock full of edge cases.
 
@StackedCrooked mostly by 0.0/0.0
but also some functions
 
> NaNs do not compare equal to 0 and thus convert to 1.
It's a footnote though, to the rule of conversion of numbers to bool.
 
NaN = Indeterminate form = Not a Number?
So would infinity/infinity = NaN?
 
5:07 AM
@Lalaland Isn't that exactly what I said?
 
@Rapptz interesting question
 
user406009
Oops bad reading on my part. Getting way too tired.
 
Here's a silly problem I saw in question earlier:
/*
    Ten cannibals begin to eat thirty missionaries. It takes an hour to consume the
    first missionary. At the end of each hour, if an entire missionary has been
    consumed, one cannibal steals away into the forest. Each of the remaining
    cannibals continues to eat at the same rate. However, as there are fewer
    consumers, fewer missionaries will be consumed in each hour. Fortunately, for
    the missionaries, help is on the way. Tarzan is coming. However, he is 80
    miles away. During the day, Tarzan travels at 7 miles per hour. During the
 
it turns out that that the problem is designed to be easily solvable with a loop that only counts up hours
 
5:10 AM
ideone updated their UI but not their compilers, lol.
At least their text editor looks pretty now.
 
what is most elegant way to support general variants?
 
@Cheersandhth.-Alf How general?
 
like, maybe two or more missionaries might get eaten each hour?
doing away with the sure assumption that at most one eat-missionary-body completed
 
I see.
 
ideaone supports an impressive amount of languages
compared to like.... lws which only has 3 afaik
 
5:18 AM
lws has newer compiler
 
Fuck. Pastebin is down at the worst time. I need to get a paste from there.
 
@Xeo Good news, first attempt at slicing ranges: "error: attempt to dereference a past-the-end iterator."
 
Xeo
5:38 AM
lol
 
Turns out I called strided(to, from) instead of strided(from, to).
Well it looks like I now have some support for random-access ranges.
> error: attempt to advance a past-the-end iterator -16 steps, which falls outside its valid range.
"some"
Taking a break and then I'll figure out what I should pass to the Boost adaptors. I need to sprinkle my code with some calls to mod.
 
Xeo
Why mod again?
 
I was looking up something on SO and I stumbled upon this stackoverflow.com/questions/860339/…
Shouldn't this have the tag?
 
Xeo
Is it frequently asked? I don't think so.
 
@Xeo Some defaults like Stride<-1> may generate negative bounds, I don't exactly remember.
 
5:44 AM
iunno, it seems like a faq type question to me.
Hmrh back to what I was looking for.
 
@Xeo Also I did in fact manage to bridge the gap between compile-time size and runtime size via... a constexpr function. Blew my mind I found a use for one of those.
 
Xeo
Heh. Transformed FromTo and friends to constexpr functions?
On a side note, I wish you could overload on constexprness of the contex the function is called in. :|
 
Given a slice Slice you can query either Slice::complete(size) or Slice::Complete<Size>. The latter is implemented in terms of the former for convenience.
 
Xeo
Btw, I think FromTo just sounds weird. Rename to Range?
@LucDanton Oh, nice.
Wait, what's complete anyways?
 
@Xeo range::slice<slices::Range<>>(v) looks dumb lol.
@Xeo It means 'fill in the defaults'.
 
Xeo
5:51 AM
@LucDanton lawl
 
Stride<-2> is a model of Slice for instance, but it's not usage until completed.
To<42>::Complete<24> is a complete slice (with bounds and a stride) but there is still some handling to be done: the upper bound would still be 42 (because it wasn't defaulted), it's up to the caller to 'adjust' to 24 if it is necessary to do so.
@Xeo I could, in fact, just call it Slice, no?
 
Xeo
Hm. Why not limit the higher index to the size?
 
Slice<From, To, Stride>
 
Xeo
A slice is a range, so meh.
 
No.
Well, depends.
In Python you pass in slice objects to [] and then generate a slice. I think.
range(5)[0::-1] is sugar for range(5)[slice(0, None, -1)]
I think you're right. In Python it works because the syntactical sugar hides the slice detail objects from you.
slice<Slice<>> isn't super nice either.
 
Xeo
5:57 AM
I think with Boost.MultiArray, you have index ranges
 
slice<To<I>> is readable, slice<From<I>> as well, slice<Stride<N>> and slice<FromTo<I, J>> not that much. You've been telling me that for some time, but I do need to fix those names.
On the other hand I can get rid of FromTo completely.
From<I>::To<J> is available. A bit heavy on the eyes.
 
Xeo
@LucDanton Having dynamic typing helps with default values :D
 
On a scale of meh, to insane. How difficult would it be to implement a LINQ like interface for stl containers
 
@Xeo Well, no.
 
Xeo
@Borgleader Meh, since all containers have iterators, which are the basis for any LINQ-like stuff.
Also, Boost.Range
 
6:10 AM
I can write an interface that accepts either Just<5> or None. But syntactically speaking it will look bad.
The real benefit is the syntactical sugar that fills in the hole with None or an appropriate value -- regardless of typing.
 
Xeo
@LucDanton Hey, you were pondering which default value to give to the To parameter.
 
@Xeo Cool, I might try to write one up :)
 
@Xeo Because I don't want to sacrifice the interface, yes. The limitation is syntax, not semantics.
 
Xeo
@Borgleader There are many out there already.
All having one flaw or another.
Good luck, though.
 
Thanks.
 
6:12 AM
Transforming [::-1] to e.g. [slice(size, None, -1)] doesn't require dynamic typing :|
 
Xeo
@LucDanton The whole point of the OP was to not have to mention a specific wrapper.
@LucDanton True enough.
 
@Xeo Whoah, why name the wrapper in the first place. Now I understand why there's a template solution.
All existing answers are terrible, because the question is terrible.
 
Xeo
Aye
 
Okay, so the parameters to sliced and strided must all be non-negative, and the upper bound must not exceed the size of the range.
Given a negative stride, I can reverse, and then slice while flipping the bounds.
 
Xeo
I think I just killed Adobe Reader by trying to expand a bookmark twice. o_o
Let's try that again...
 
6:19 AM
Given two negative bounds, I can modulo to adjust them.
 
Xeo
No nevermind, the "Expand current bookmark" blows it up all by itself.
 
Given mixed bounds... well that sucks!
Oh, I have an issue. Reversing means changing the type.
 
Xeo
@LucDanton Oh oh.
Btw, where exactly does the standard say that any pointer past the "past the end" marker is invalid?
 
Expressions, operator +.
 
Xeo
Can't find it there.
 
6:26 AM
It's not so much that the pointer is invalid, it's that computing a pointer outside the bounds of an array is UB.
 
Xeo
Oh, wait, there it is
> If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined.
 
Holy smokes, since the last time I checked in here this room appears to have spawned its own wiki!
 
@Grigory Hi. When was that?
 
Xeo
@Grigory We have spawned much more, including mayhem, downvotes, FAQs and more mayhem on meta.
 
hi
 
6:27 AM
I think it was more than a year ago :)
 
want to ask something tin this program
what this is doing in while loop first[a[c]-'a']++;
 
lol that is pretty bad
it's subtracting ascii 'a' from the value of a[c] to access the array first and increments it by one.
 
Cute code. How evil.
 
so 'a' mean its getiing ASCII code ???
 
hello guys I am studying algorithms and have a question about my solution. The author of the book I am using seems to suggest a different solution than the one I came about. Anyone care to help?
 
6:33 AM
fancy way of saying 97.
 
@Rapptz r u taking to me ?
 
Xeo
 
can you explain what the while loop is actaually doing
 
Let's keep in mind that it's not a given that the execution encoding is ASCII (or a superset of it) in C++. The program is relying on a further assumption.
 
6:35 AM
ok Xeo thanks for the link, I was just hoping to catch someone here to discuss rather than just do a quick Q&A, since I technically already have my answer.
 
Yeah, are you using a computer from 1960s? Nah, I kid.
 
Xeo
Actually, maybe CodeReview.SE might be a good place to ask.
 
Ok thanks
 
@Rapptz Using u8'a' would document the assumption in the most straightforward manner.
Or document that the expected encoding is UTF-8, works too.
 
why its subtracting a[c]-'a' ACII dec value :/
 
6:37 AM
It's easier to list those that wouldn't have that encoding imo.
Unless you're telling me that the 3 major operating systems would handle subtracting 'a' differently. Cause I guess I wouldn't know, but of all machines I've used it ended up fine.
 
Xeo
@DextOr Two arrays, one for each input string, for the number of occurences every character in the alphabet has. Then iterating over each string, and getting the index of the letter with the substraction ('a' - 'a' == 0, 'b' - 'a' == 1, etc.). So first[0] represents the number of 'a's in the string, first[1] the number of 'b's and so on.
17 answers left...
 
ohhhh wow ... it is actually matching the index A-Z ...... ok thanks @Xeo for good explanation :D
 
Xeo
Btw that code is assuming all-lowercase strings.
 
it's also pretty ugly
 
Xeo
It's C
And for C, it's actually not even that ugly
And with that, off to sleep.
 
6:51 AM
@Rapptz I can effortlessly compile a program that uses EBCDIC as the execution encoding. I'm not sure if my terminal support it to e.g. display the output correctly, but in any case no OS support is required.
 
You'd still have to go out of your way to do it.
 
17 mins ago, by Rapptz
It's easier to list those that wouldn't have that encoding imo.
You made that claim.
 
You can invoke it differently but would most go out of their way to do it?
 
Oooooooooor you could use u8'a'.
 
And if you're using pre-C++11?
 
6:59 AM
Comment, hardcode. I don't care for the original program -- it's dishonest to mislead beginners to think that 'a' is the ASCII value 97 however.
Please don't do it.
 

« first day (744 days earlier)      last day (4220 days later) »