code logs -> 2011 -> Sat, 10 Dec 2011< code.20111209.log - code.20111211.log >
--- Log opened Sat Dec 10 00:00:11 2011
00:00 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
00:14 io\afk is now known as iospace
00:28 cpux|2 is now known as cpux[Skyrim]
00:35 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
01:05 Attilla_ [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
01:05 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
--- Log opened Sat Dec 10 01:47:58 2011
01:47 TheWatcher [chris@Nightstar-3762b576.co.uk] has joined #code
01:47 Irssi: #code: Total of 27 nicks [4 ops, 0 halfops, 0 voices, 23 normal]
01:48 Irssi: Join to #code was synced in 39 secs
02:02 Derakon is now known as Derakon[AFK]
02:18 Attilla_ [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
02:18 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
02:29 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
02:40 Kindamoody[zZz] is now known as Kindamoody
04:02 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has quit [Ping timeout: 121 seconds]
04:18 * McMartin writes some type inference code, because he can.
04:23
< celticminstrel>
Heh.
04:30 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
04:33
< McMartin>
Unfortunately now we move into the parts where type checking should happen, which means actually using and maintaining environment structures.
04:33
< McMartin>
That feels far too much like work.
04:33 * McMartin goes to eat tacos instead.
04:51
< Ling>
http://www.computerworld.com/s/article/9222503/Java_apps_have_most_flaws_Cobol_a pps_the_least_study_finds
04:52
< Reiver>
COBOL is hard.
04:52
< Reiver>
It demands you pay attention.
04:52
< Reiver>
It's also used in fairly rare places these days; such places tend to be unforgiving.
04:53
< McMartin>
COBOL is really a domain-specific language for parsing huge stacks of punchcards.
04:53
< Ling>
They say it's because of code-maturity :/
04:54
< Ling>
Thus Java could have the least if it were used in the oldest code-bases.
04:54
< McMartin>
And if no new code were being written in it
04:54
< ToxicFrog>
Ling: well, yeah - the only COBOL apps still in use are the huge, super-mission-critical ones that people have been tiptoeing around for decades.
04:55
< ToxicFrog>
No-one's writing new COBOL apps, they're just polishing up existing ones, and all of the existing ones are the ones that work well enough to be kept around for a very long time.
04:55
< ToxicFrog>
It's the "everything was better on the NES" effect applied to programming languages. It's not that everything's better in COBOL, it's that by and large, the only surviving COBOL apps are the good ones.
04:56
< Reiver>
Hey, people still write COBOL
04:56
< Ling>
Like that one IRC bot a friend made as a joke
04:56
< Ling>
(He also made a prolog one)
04:56
< ToxicFrog>
On the flip side, Java has become the closest thing there is to an official language for when you have a large number of people who can't program but you need them to develop a program.
04:57
< Ling>
That's for the quotefile now.
04:57
< Reiver>
TF: A pity it wasn't Python~
04:57
< Ling>
Python requires thinking
04:58
< McMartin>
Python has a lot of the safeties off.
04:58
< McMartin>
Though, as I am noticing, it still has more safeties than Scheme!
04:59 * McMartin may have attempted to assign one field in his structure and wound up splicing the value across six.
05:01
< ToxicFrog>
oops
05:02
< Eri>
Toxic: Nope nope. I'm going to say that's Labview, not Java
05:03
< Eri>
Java, you at least understand what's happening inside the computer
05:04
< ToxicFrog>
Eri: no, Labview is for electronic engineers.
05:05
< ToxicFrog>
Java is "we have three dozen people who claim to have programming degrees but cannot actually program, and need to turn this into working "enterprise-grade" software"
05:06 cpux[Skyrim] is now known as cpux
05:07
< McMartin>
Note that if you have a team of seriously good programmers who are also skilled at Java and its idioms, you can get some seriously rock-solid stuff.
05:08
< Ling>
Until the maintenance team gets there with their fresh-out-of-college body.
05:08
< McMartin>
The non-ironic enterprise-grade stuff.
05:10
< McMartin>
Java has a number of fairly serious linguistic shortcomings, and in general I refuse to work in any library-heavy OO language without an IDE that's intimately familiar with the language and the libraries linked against, and which is capable of automatic refactoring
05:10
< McMartin>
Happily, Eclipse exists~
05:10
< McMartin>
This works around pretty much all of the problems except for the ugliness of method pairing in Java.
05:10
< ToxicFrog>
Yeah; while I have many objections to Java as a language, none of them really interfere with the ability to make top-notch software in it, just the enjoyability of writing it~
05:11
< McMartin>
(I'm one of those cranks who considers single-inheritance-only for implementation an a universal Object type actually good ideas~)
05:11
< McMartin>
(But even there C# does it better)
05:11
< McMartin>
(The ability to independently define implementations of functions when cast to interfaces with namespace collisions is a major refinement.)
05:11
< Ling>
It's getting better though, one day it'll have real callbacks that don't need a full class-definition or reflection (both of which rape the line count into a bloated mess)
05:12
< McMartin>
Put them into "this" like a real man~
05:12
< McMartin>
(I'm *mostly* kidding. But you can get away with it with frightening frequency)
05:12
<@Namegduf>
I'm beginning to learn to tolerate working in Eclipse.
05:12
< McMartin>
(But that particular little issue is one reason I write Java witha noticable functional accent)
05:13
<@Namegduf>
It has an infuriating combination of the "do everything for you" approach of "user-friendly" software
05:13
<@Namegduf>
With the difficulty of operation of a program whose manual must be read to understand the available operations
05:13
< McMartin>
Also, Ling, it will of course *have* a full class-definition; it will just hide it like it does for access to non-static nested scopes
05:13 * Ling can't stand IDEs at all
05:14
< Ling>
The "do everything" ends up being really restricted, or tedius.
05:14
<@Namegduf>
So at first shit happens and you've no idea what the shit was or why. It's like vim if vim liked to switch modes on its own.
05:14
< McMartin>
It's more that for things like Java, I consider access to automated syntax transformers basically mandatory.
05:14
<@Namegduf>
When you've got used to it it is *less* bad.
05:14
<@Namegduf>
Yeah, Java really needs IDE autogeneration of things.
05:14
<@Namegduf>
And autocompletion.
05:14
<@Namegduf>
It's just that verbose.
05:15
< McMartin>
However - and this is where I'm getting stung in Scheme - I do *not* like having automatic syntax transformation being a standard build step.
05:15
< McMartin>
And there seems to be an expectation that you're going to be extending the syntax at least *some* for any significant project, and I resist this.
05:16
< McMartin>
If I do ever end up needing the define-values macro, which the dialect I'm using lacks, I'll have to make some exceptions, though.
05:17
< celticminstrel>
"people who claim to have programming degrees but cannot actually program" ... heh, I think I might know some such people or future such people. <_< It's amazing how many people in the compsci program don't understand things. Professors sometimes as well, like the software engineering one who didn't seem to understand JavaScript at all despite making us use it, and who showed a C++ example that was like "class x : public B { B
05:17
< celticminstrel>
thing;};".
05:18
<@Namegduf>
I definitely have worked with some of those people.
05:19
< celticminstrel>
[Dec 10@12:11:03am] McMartin: (I'm one of those cranks who considers single-inheritance-only for implementation an a universal Object type actually good ideas~)
05:19
< celticminstrel>
I have nothing against a universal Object, but I do like my multiple inheritance. >_>
05:19
< celticminstrel>
There have been times with Java that I wish I had it.
05:19
<@Namegduf>
In that kinda scenario I'd refactor to use composition.
05:19
<@Namegduf>
Actually I'd use composition to begin with.
05:19
<@Namegduf>
But that's me.
05:20
< ToxicFrog>
I go back and forth on single-inheritance-only; on the one hand MI is fraught with spiders, on the other hand I do occasionally find myself reaching for the mixins.
05:20
< celticminstrel>
Even if it's an is-a relationship?
05:20
<@Namegduf>
I do not model relationships in code.
05:20
< ToxicFrog>
Universal Object is pretty nice; it's a shame Java doesn't have it.
05:20
< celticminstrel>
XD
05:20
<@Namegduf>
is-a is a delusion.
05:20
<@Namegduf>
Mostly.
05:20
< celticminstrel>
Uhuh.
05:21
<@Namegduf>
Our concepts are actually quite vague about what makes something qualify as being something.
05:21
<@Namegduf>
Circle vs Ellipse and Bird + Ostrich are the classic examples of problems.
05:23
<@Namegduf>
Trying to model them using something as limited as inheritance is both unnecessary and I think unhelpful.
05:23
<@Namegduf>
It makes things look pretty for managers, I'm sure.
05:24
<@Namegduf>
Oh, and Bag-of-Apples vs Bag-of-Fruit,
05:24
< McMartin>
21:19 <@Namegduf> Actually I'd use composition to begin with.
05:24
< McMartin>
21:19 <@Namegduf> But that's me.
05:24
< McMartin>
It is not just you
05:24
< McMartin>
Bag of apples vs. Bag of Fruit is something Java gets right as of... 1.5, I believe.
05:25
<@Namegduf>
Well, I'm more listing cases where "is-a" is complicated.
05:25
< McMartin>
Yeah
05:25
< ToxicFrog>
But they both look like empty bags once it's compiled~
05:25
< McMartin>
And it's also a case that, for instance, early versions of C++ got flatly wrong.
05:25
<@Namegduf>
Heh.
05:25
<@Namegduf>
Ah.
05:25 * celticminstrel was hoping for notes on why it's complicated there, but eh.
05:26
<@Namegduf>
In the case of bag of fruit vs bag of apples, it's about the operations you can do on each.
05:26
< celticminstrel>
And what did early C++ get wrong?
05:26
<@Namegduf>
You can put oranges in a bag of fruit, but not in a bag of apples.
05:26
< celticminstrel>
True...
05:26
<@Namegduf>
This means that a bag of apples can only be considered a subtype of bag of fruit if it is immutable.
05:26
<@Namegduf>
Circls vs Ellipse is similar.
05:27
<@Namegduf>
The ways you can resize a circle are more limied.
05:27
<@Namegduf>
*limited
05:27
< celticminstrel>
I would say circle is-a ellipse, but not something that'd merit a separate class...
05:27
<@Namegduf>
And the assumptions you can make for an circle's shape are not provided for ellipses.
05:27
< celticminstrel>
Also true.
05:28
<@Namegduf>
And if your circle class inherited from your ellipse class, if you provided a resizing mechanism you'd have created a broken model.
05:28
< Ling>
TBH, since a Circle is a simpler object, it should be the base class.
05:28
<@Namegduf>
Because you could resize circles into shapes which weren't valid for them.
05:28
< celticminstrel>
...I suppose bird+ostrich has "ostrich can't fly" as a complication.
05:28
<@Namegduf>
Yep.
05:28
<@Namegduf>
That's doable if you provide bird with that limitation in the first place.
05:28
< celticminstrel>
For the circle/ellipse one I probably wouldn't even have two separate classes. <_<
05:28
< ToxicFrog>
That's only a complication if you make the assumption that all Birds can fly~
05:29
<@Namegduf>
But if you're implementing an ostrich later you're screwed.
05:29
<@Namegduf>
ToxicFrog: The point is that virtually any defining feature of many concepts
05:29
<@Namegduf>
Has stuff in that concept for which it is not the case
05:29
<@Namegduf>
What CAN birds do, generically?
05:29
<@Namegduf>
In the example of a "Bird->FlyingBird" case I saw, it had something like "peck"
05:29
< celticminstrel>
I don't know...
05:29
< ToxicFrog>
Grow feathers, lay eggs, generate internal heat
05:29
<@Namegduf>
Are there any birds which can't peck?
05:30
< ToxicFrog>
Lots.
05:30
< ToxicFrog>
(unless you count clubbing something ineffectually with a bill as "pecking", which I don't)
05:30
<@Namegduf>
Yeah.
05:31
<@Namegduf>
Those weren't even modeled because they weren't of interest.
05:31
<@Namegduf>
And if they were it probably wouldn't be very useful to operate on things which provide just those guarantees.
05:31
< celticminstrel>
Yeah.
05:32
<@Namegduf>
Ling: The problem with Ellipse as a subclass of Circle is that circle provides guarantees that ellipse won't.
05:32
< ToxicFrog>
But, yeah, what this seems to boil down to is "not everything can or should be usefully modeled with inheritance relationships", which I don't think anyone disagrees with.
05:32
<@Namegduf>
It's a more subtle problem and you can probably write something that compiles
05:32
<@Namegduf>
But's a bug
05:32
< ToxicFrog>
OTOH, my GamePiece damn well is-a Token and modeling it as such simplifies things immensely.
05:33
<@Namegduf>
You're not meeting the guaranteed behaviour of the parent class.
05:34
<@Namegduf>
Yeah, in some cases it works fine.
05:34
<@Namegduf>
I don't think it's a useful goal in itself to set out for, modeling relationships, though.
05:35
<@Namegduf>
In abstract cases where you're basically creating the relationships from scratch, you're modeling things which don't really carry meaning. GamePiece is-a Token because you defined both of them yourself in such a way that it was.
05:37 cpux is now known as cpux[Skyrim]
05:37
<@Namegduf>
That's actually where it shines in practical use I think- you actually can provide hard, reliable information on what is-a what, where is-a means what inheritance means.
05:37
<@Namegduf>
But it's useful for maintainability gain, not anything else modeling might provide.
05:37
<@Namegduf>
That's what I think.
05:42
<@Namegduf>
All this reminds me of a JVM language which had a page announcing they were going to do bag of apples and bag of fruit wrong on purpose.
05:43
<@Namegduf>
"Let's make a deal: You don't do that."
05:43
<@Namegduf>
So their containers of subtypes could be used as containers of supertypes.
05:43
<@Namegduf>
It was a bit amusing.
05:44
< McMartin>
Heh
05:44
< McMartin>
Also, >_<
05:44
< McMartin>
I've mentioned before that I was looking into setting up some subset of Pascal or something to be a useful HLL for compilation to 8-bit machines
05:44
< celticminstrel>
Technically Java does that too. <_<
05:45
<@Namegduf>
Java does it at runtime, but the type checker runs at compile-time, so I don't think it counts.
05:45
< McMartin>
I fiddle with this a bit before I realize I am basically reinventing QBASIC poorly.
05:45
< McMartin>
Also, as of 1.5, Java does it at compile time if you don't pre-type-erase your stuff.
05:45
< celticminstrel>
Well, you can always do an unsafe cast though.
05:45
<@Namegduf>
Yeah. To be fair it whines at you if you do.
05:46
< celticminstrel>
Yeah, but it lets you.
05:46
<@Namegduf>
Unsafe casts being able to circumvent a type checker don't count; you're expressly asking it to step aside and it shouldn't be expected to second guess you.
05:46
<@Namegduf>
I'm also not sure it WILL work.
05:46
<@Namegduf>
I think the cast will just explode.
05:46
< McMartin>
IllegalClassCastException.
05:47
<@Namegduf>
Yeah.
05:47
< celticminstrel>
At runtime, yes.
05:47
<@Namegduf>
On thought, it might not even let you cast.
05:47
<@Namegduf>
Java will compile-time check casts some.
05:47
< McMartin>
However, again, in 1.5, attempting to pass a Bag of Apples to something that expects a Bag of Fruit will refuse to compile.
05:48
< McMartin>
The other direction... it depends.
05:48
< celticminstrel>
Fairly sure it'll allow it if you cast.
05:48
< McMartin>
You have to mark whether you're going to be inserting, removing, or both
05:48
< celticminstrel>
...why are we talking about 1.5, anyway, when 1.7 is just opened up?
05:48
<@Namegduf>
Probably 1.7 didn't change it.
05:49
<@Namegduf>
Be weird if they rewrote all this rules each release.
05:49
< celticminstrel>
Well no, it wouldn't've... I think Java has laws against breaking backwards compatibility or something. :|
05:49
<@Namegduf>
In general, I think Java will reject casts at compile-time if the type being cast to is not a subclass of the type being cast from.
05:49
<@Namegduf>
Or a superclass, I guess.
05:49
< celticminstrel>
Maybe someday there'll be a 2.0 that does break backwards compatibility.
05:50
< celticminstrel>
Yeah, but weren't we talking about containers?
05:50
<@Namegduf>
Yes, but I don't think different instantiations of containers count as sub or superclasses of each other.
05:50
< celticminstrel>
A container of one type can be cast to a container of any type.
05:51
< ToxicFrog>
celticminstrel: OH GOD I WISH
05:51
<@Namegduf>
Are you sure?
05:51
<@Namegduf>
I don't understand why they'd allow that, because it will *never* work.
05:51
< ToxicFrog>
Being able to finally ditch binary compatibility with ancient versions of Java would make the JVM so much nicer.
05:51
< celticminstrel>
Because under the hood they're all just containers of Object.
05:51
<@Namegduf>
Yes, but the compile-time type checker does not care about that.
05:52
<@Namegduf>
It still has the types.
05:52
< celticminstrel>
ToxicFrog: Heh, for a moment I thought you were reacting to the line right above you. :P
05:52
< McMartin>
You can do type erasure by hand
05:52
< celticminstrel>
And yes, the compiler cares, unless you tell it not to by explicitly putting in the cast.
05:52
< McMartin>
I do not know if you can do a cast to LinkedList<Object> though
05:52
<@Namegduf>
No, the compiler will NOT permit all casts.
05:52
<@Namegduf>
That is what I said.
05:52
<@Namegduf>
05:49 <@Namegduf> In general, I think Java will reject casts at compile-time if
05:52
<@Namegduf>
the type being cast to is not a subclass of the type being
05:52
<@Namegduf>
cast from.
05:52
<@Namegduf>
05:49 <@Namegduf> Or a superclass, I guess.
05:53
<@Namegduf>
If the compiler can trivially tell the cast will never be able to be successful
05:53
<@Namegduf>
It will reject at compile-time
05:53
< McMartin>
Right
05:53
< celticminstrel>
Right, but I'm not talking about casts in general, only about casts between containers.
05:53
<@Namegduf>
Right, but it can tell, trivially, between containers.
05:53
< celticminstrel>
Like, List<Integer> and List<String>.
05:53
< celticminstrel>
You can cast between them.
05:54
< celticminstrel>
It would be a stupid thing to do, but you can do it.
05:54
<@Namegduf>
test.java:5: inconvertible types
05:54
<@Namegduf>
found : java.util.ArrayList<java.lang.String>
05:54
<@Namegduf>
required: java.util.ArrayList<java.lang.Integer>
05:55
<@Namegduf>
The line in question is: ArrayList<Integer> foo = (ArrayList<Integer>)new ArrayList<String>();
05:55
< celticminstrel>
Okay, so you can't cast directly.
05:55
<@Namegduf>
Like I said; the compiler can trivially tell that that would never work because they aren't sub or supertypes of each other.
05:55
<@Namegduf>
So it rejects the cast at compile-time.
05:55
< ToxicFrog>
Will it let you cast List[Int] -> List[Object] -> List[String]?
05:56
< celticminstrel>
ArrayList<Integer> foo = (ArrayList<Integer>)((ArrayList)new ArrayList<String>); ?
05:56
<@Namegduf>
It won't let me cast List[Int] -> List[Object]
05:56
<@Namegduf>
With the same error
05:56
<@Namegduf>
Yeah, if you go via type erasure, you can do it, but you're not supposed to use type erasure at *all*.
05:57
< celticminstrel>
Still counts. :P
05:57
<@Namegduf>
Not really.
05:57
<@Namegduf>
It refuses to build.
05:57
<@Namegduf>
You need to provide an extra parameter to tell it to.
05:57
<@Namegduf>
I think.
05:57
<@Namegduf>
Ah, no, that's something else. It's just a warning.
05:58
<@Namegduf>
But really, at that point you're abusing legacy support.
05:59
< celticminstrel>
It's not something I would do.
05:59
<@Namegduf>
I feel my original point that Java will not let you cast containers of one type to containers of another type holds.
05:59
<@Namegduf>
You can cast to a container of no type in both directions
05:59
<@Namegduf>
Which may get the same effect (of a runtime exception)
05:59
< ToxicFrog>
Namegduf: you're not supposed to use type erasure at all, and yet, it is mandatory >.<
05:59
< McMartin>
Downcasting, IIRC, generates an enumerated element check.
05:59
<@Namegduf>
But it won't let you do the thing I said it wouldn't let you do.
06:00
< ToxicFrog>
And yeah, if you abuse type erasure to try this at runtime you get a ClassCastException, IIRC
06:00
< celticminstrel>
Yup.
06:00
< celticminstrel>
(Bedtime now.)
06:01 celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
06:26 cpux[Skyrim] is now known as cpux
06:34 iospace [Alexandria@Nightstar-635d16fc.org] has quit [Ping timeout: 121 seconds]
06:43 iospace [Alexandria@Nightstar-635d16fc.org] has joined #code
09:30 AnnoDomini [annodomini@Nightstar-4ea39ceb.212.getinternet.no] has joined #code
09:47 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
10:15 Eri [Eri@Nightstar-3e5deec3.gv.shawcable.net] has quit [Ping timeout: 121 seconds]
10:28 Eri [Eri@Nightstar-3e5deec3.gv.shawcable.net] has joined #code
10:42 You're now known as TheWatcher[afk]
11:10 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [Ping timeout: 121 seconds]
11:26 Kindamoody is now known as Kindamoody|afk
12:42 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
12:42 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
12:44 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Client closed the connection]
12:44 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
12:45 Attilla_ [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
12:45 Attilla_ [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Client closed the connection]
12:46 Attilla_ [Obsolete@Nightstar-fc96e972.as43234.net] has joined #code
12:49 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
12:49 Attilla_ is now known as Attilla
12:53 Attilla [Obsolete@Nightstar-fc96e972.as43234.net] has quit [Ping timeout: 121 seconds]
13:04 AnnoDomini [annodomini@Nightstar-4ea39ceb.212.getinternet.no] has quit [[NS] Quit: Time to go.]
13:22 Kindamoody|afk is now known as Kindamoody
13:33 Netsplit *.net <-> *.split quits: Alek, jerith, Reiver
13:33 jerith [jerith@Nightstar-bf52129d.slipgate.za.net] has joined #code
13:33 Netsplit over, joins: Alek
13:35 RichardBarrell [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
13:37 Kindamoody is now known as Kindamoody|out
13:39 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
13:47 gnolam [lenin@Nightstar-202a5047.priv.bahnhof.se] has joined #code
14:10 AD[Shell] [abudhabi@Nightstar-131e1d92.adsl.inetia.pl] has quit [Ping timeout: 121 seconds]
14:15 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
14:18 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
14:20 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
14:21 AnnoDomini [annodomini@Nightstar-f7eedefa.80-203-17.nextgentel.com] has joined #code
14:51 Attilla_ is now known as Attilla
14:52 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [[NS] Quit: ]
15:02 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
15:02 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:02 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:06 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
15:10 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:10 celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code
15:11 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
15:13 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:14 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
15:27 Rhamphoryncus [rhamph@Nightstar-14eb6405.abhsia.telus.net] has joined #code
15:30 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
15:31 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:37 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:38 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
15:42 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
15:45 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
15:47 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
15:47 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
15:49 * Tamber mallets Geomyidae's upstream.
15:49
< Tamber>
Damnit! Don't change the contents of the tarball and leave it with the same version number and location!
15:52 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
15:52 Kindamoody|out is now known as Kindamoody
15:53 * Tamber grumble.
16:10 You're now known as TheWatcher
16:18 RichardBarrell [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has quit [Ping timeout: 121 seconds]
16:22 Kindamoody is now known as Kindamoody|out
16:34 RichardBarrell [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has joined #code
17:03 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [[NS] Quit: Into the hole again, we hurried along our way, into a once-glorious garden now seeped in dark decay.]
17:05 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
17:06 Derakon[AFK] is now known as Derakon
17:23 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
18:01 AnnoDomini is now known as Birds
18:01 Ling is now known as Shoat
18:03 EvilDarkLord is now known as Shield
18:15
< gnolam>
Ahh, that magical wxPython code quality.
18:15
< gnolam>
import wx.grid as gridlib
18:15
< gnolam>
Congratulations, you obfuscated the origin of a bunch of classes to save on typing all of... uh... 0 characters.
18:28
< RichardBarrell>
<advocate for="devil">That does saves invoking the bytecode that implements __getattr__(wx, "grid") every time you refer to gridlib.</advocate>
18:30
< RichardBarrell>
But if you care about that kind of bullshit micro-optimisation then you should just ditch CPython in the first place. At the very least, write your code against PyPy or Pyrex instead; or even switch to C where micro-optimisations almost completely stop mattering for most code.
18:30
< RichardBarrell>
Plus, you're writing code that runs a fucking GUI. Every window-drawing call invokes ten-thousands of instructions. Who gives a shit if it takes an extra fifty cycles to invoke?
18:44
< jerith>
Doesn't it look up "wx.grid" in sys.modules?
18:44
< RichardBarrell>
Good question, I should try it to be sure.
18:45
< jerith>
I know when I import "os.path", I get "os.path" in sys.modules.
18:46
< RichardBarrell>
It isn't looked up from there.
18:46
< RichardBarrell>
*Yes, the module gets put there too, but that isn't where code will look it up from.
18:48
< RichardBarrell>
"import foo" adds a global called "foo" to the current module, which is where running code will look it up. I think that the entry in sys.modules is only looked up when a second "import foo" is run, in order to have only one copy of the foo module.
18:48
< RichardBarrell>
import wx.grid; import wx.grid as gridlib; import dis
18:48
< RichardBarrell>
dis.dis(lambda : wx.grid.cvar)
18:49
< RichardBarrell>
emits: LOAD_GLOBAL (wx), LOAD_ATTR(grid), LOAD_ATTR(cvar), RETURN_VALUE
18:49
< RichardBarrell>
while dis.dis(lambda : gridlib.cvar)
18:49
< RichardBarrell>
emits: LOAD_GLOBAL (gridlib), LOAD_ATTR(cvar), RETURN_VALUE
18:49
< jerith>
Ah, cool.
18:50
< RichardBarrell>
The "dis" module is part of the python standard library since whenever (at least as far back as 2.4, which is effectively forever for my purposes) and is pretty fun to play with.
18:50
< RichardBarrell>
A word of advice about python internals: never, ever make the mistake of assuming that anything that the CPython implementation does is sane, because there's a lot of crazy suboptimal hidden down there. ;)
18:51 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has joined #code
18:51 * jerith spent the afternoon talking to one of the pypy core devs.
18:51
< jerith>
So I know that already.
18:53
< Shoat>
How does PyPy work anyways? Doesn't it still need another python implementation?
18:54
< celticminstrel>
...PyPy?
18:54 RichardBarrell [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has quit [Ping timeout: 121 seconds]
18:59
< Shoat>
Python implementation written in Python IIRC
19:00
< celticminstrel>
What about Pyrex
19:00
< celticminstrel>
?
19:02<~Vornicus> Pyrex is a thing that compiles python or c-python hybrid code to c-compiled modules for python.
19:02<~Vornicus> Pypy actually does jit compiling to machine code.
19:02
< jerith>
Shoat: pypy is mostly written in rpython, which is a statically-typed language that looks a lot like Python and implements a bunch of Python-like features.
19:03
< jerith>
rpython is basically a language designed specifically for writing Python interpreters.
19:03
< jerith>
rpython is implemented in Python, so you need a Python interpreter to run rpython.
19:05
< jerith>
The rpython gets translated (compiled, basically) to one of a number of target languages. The most common is Intel asm (via C or something, probably -- I forget) but there's also one for the jvm, as I recally.
19:05
< jerith>
*recall
19:06
< jerith>
Once you've done the compilation step, you have a native binary for the platform of your choice.
19:06
< jerith>
(I'm not an expert, so I may have oversimplified or got some details wrong.)
19:08<~Vornicus> So they wrote pypy in rpython, and then compiled it, and that's what you download, so you don't need python?
19:08
< jerith>
Yes.
19:08
< jerith>
Although you need Python if you want to build pypy from source.
19:08
< jerith>
(You also need at least 4Gb RAM available and probably an hour or so.)
19:10
< jerith>
You /can/ run an interpreted pypy directly on top of Python without doing the translation step, but the only reason you'd ever want to do that is to debug obscure things.
19:10<~Vornicus> (that seems a little bit ridiculous)
19:10
< jerith>
It's so horribly slow that it takes several minutes for the interpreter to start up.
19:10<~Vornicus> (the 4gb thing, that is)
19:11
< jerith>
It's a hefty codebase, and it does a lot of stuff.
19:12
< celticminstrel>
Which one takes several minutes to start up... rpython, or PyPy?
19:13
< jerith>
(I've done the py.py thing myself when I was trying to figure out why pygame didn't run on pypy. It was crashing somewhere in the C-extension API layer, and the translated pypy wasn't giving me useful traces.)
19:14
< jerith>
celticminstrel: The whole py.py stack. It's Python running the rpython interpreter running pypy.
19:14 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [Client closed the connection]
19:14
< jerith>
The whole CPython extension compat thing is made of spiders.
19:15
< celticminstrel>
Oh you mean when running PyPy directly on Python.
19:15
< jerith>
pypy doesn't have CPython's refcounting GC, so it has to fake all the reference stuff for the extensions.
19:16
< jerith>
It also has to manufacture stack frames for things that don't exist in pypy and stuff.
19:16
< celticminstrel>
Like?
19:17
< jerith>
I don't recall offhand.
19:17
< jerith>
Stuff that gets jitted away or something, perhaps.
19:18
< jerith>
Basically, it has to pretend to be cpython so the C code that expects cpython internals can work.
19:45 Attilla_ [Obsolete@Nightstar-b8e915be.as43234.net] has joined #code
19:46 Attilla [Obsolete@Nightstar-b8e915be.as43234.net] has quit [Ping timeout: 121 seconds]
19:46 Attilla_ is now known as Attilla
20:13 PinkFreud [WhyNot@NetworkAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
20:19
<@Tarinaky>
Argh. I can't remember how to do list comprehensions in Python.
20:19
<@Tarinaky>
Is this right? midpoint_x = [ x for (x,a,b) in PointList ]
20:21
< jerith>
Assuming PointList is a list of three-tuples, yes.
20:21
< celticminstrel>
Looks it.
20:21
<@Tarinaky>
No... Wait.
20:21 * Tarinaky facepalms.
20:21
<@Tarinaky>
I want to add all the xs together and divide by a scalar.
20:23
<@Tarinaky>
So is that foo + x for x in ... ?
20:24
< jerith>
sum([x for x, a, b in PointList]) / scalar
20:25
< jerith>
If x is big, you might want to use reduce() or something.
20:25
<@Tarinaky>
Isn't there a list comprehension way of doing it?
20:25
< jerith>
A list comprehension is syntactic sugar for map().
20:25
< jerith>
Well, map()/filter().
20:25
<@Tarinaky>
Yes. Because map() is fucking insane to remember how to use correctly and read >.>
20:26
< jerith>
Listcomps are nicer than map()/filter().
20:26
<@Tarinaky>
Exactly.
20:26
< jerith>
But they don't really do reduce().
20:26
<@Tarinaky>
So is there a listcomp way of doing sum?
20:26
< jerith>
No, because it's effectively a reduce() operation.
20:26
< celticminstrel>
(x for x, a, b in PointList) is the iterator form of a list comprehension.
20:27
<@Tarinaky>
What's the difference between sum and reduce?
20:27
< jerith>
However, you can wrap the listcomp in sum()
20:27
< celticminstrel>
Which might be good to use if the PointList is large. <_<
20:27
<@Tarinaky>
PointList is only 3 3-tuples >.>
20:27 * celticminstrel shrugs. :P
20:28
< jerith>
sum() is basically reduce(lambda a, b: a + b, sequence).
20:28
< jerith>
Although I think it has a more task-specific implementation.
20:46
<@Tarinaky>
I see.
20:46 Kindamoody|out is now known as Kindamoody
20:47
< jerith>
As celticminstrel says, though, you should probably use generator expressions instead of listcomps if you're just doing it to get the sum or whatever.
20:49 * gnolam arrrrrrrrrghs at wxPython
20:49
< jerith>
GUI libraries are pain.
20:52
< gnolam>
GUI /everything/ is a pain.
20:52
< gnolam>
But something is seriously _broken_ here.
20:55
< gnolam>
It's fucking up layout it shouldn't be able to fuck up.
20:57
< jerith>
It's a GUI library.
20:57
< jerith>
It can fuck up /anything/.
20:57 Derakon [Derakon@Nightstar-f68d7eb4.ca.comcast.net] has quit [Ping timeout: 121 seconds]
20:58 Derakon [Derakon@Nightstar-f68d7eb4.ca.comcast.net] has joined #code
21:07
<@Tarinaky>
I'm not sure if I'm commiting a brainfart.
21:07
<@Tarinaky>
but if I have 3 points in space - shouldn't the midpoint between them lie on the plane defined by those 3 points?
21:07
< gnolam>
Yes.
21:08
<@Tarinaky>
Second question: why is my code not working then
21:09
<@Tarinaky>
midpoint_x = sum( x for (x,a,b) in pointList ) /3 # repeated in 3 dimensions; where pointList has 3 elements.
21:11
< jerith>
I'm not sure that what you're trying to do there makes sense.
21:12
<@Tarinaky>
There's 2 other lines.
21:12
<@Tarinaky>
midpoint_x = sum( x for (x,a,b) in pointList ) /3 midpoint_y = sum( y for (y,a,b) in pointList ) /3 midpoint_z = sum( z for
21:12
<@Tarinaky>
(z,a,b) in pointList ) /3 midpoint = (midpoint_x,midpoint_y,midpoint_z)
21:12
<@Tarinaky>
And copy+paste fails once again :/
21:13
< jerith>
I suppose it depends on what you mean by "midpoint".
21:13
< Derakon>
This is the same pointList each time?
21:13 * Tarinaky nosecolas
21:13
<@Tarinaky>
I am an idiot.
21:13
< Derakon>
All three of your midpoints are the same value.
21:13
<@Tarinaky>
Yes.
21:13
< Derakon>
(Just replace "(x,a,b)" with "(x,y,z)")
21:14
< jerith>
Oh, right. I assumed you were actually using the correct elements.
21:14
< jerith>
You can probably do that better with zip() or something.
21:14
<@Tarinaky>
Curiously... That didn't actually work.
21:15
< Derakon>
If pointList were a numpy array you could just do sum(pointList, axis = 0).
21:15
<@Tarinaky>
I've changed it so it's (x,y,z) and it... err... produced the same error :/
21:17
< jerith>
Integer aritmentic?
21:17
< jerith>
*arithmetic
21:18
< jerith>
In [6]: pointlist = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
21:18
< jerith>
In [7]: tuple(float(sum(a)) / len(pointlist) for a in zip(*pointlist))
21:18
< jerith>
Out[7]: (4.0, 5.0, 6.0)
21:19
< jerith>
(That's a little less clear, but more concise.)
21:19
<@Tarinaky>
I really don't like zip.
21:20
<@Tarinaky>
Changing it to float(x) for (x,y,z) in list worked.
21:20
<@Tarinaky>
Cheers.
21:20
<@Tarinaky>
:D
21:21
< jerith>
Why don't you like zip()
21:21
< jerith>
?
21:22
<@Tarinaky>
I find it difficult to understand.
21:23
<@Tarinaky>
Also, what's *pointlist?
21:23
< jerith>
It's not hard to understand in isolation, but it tends to make stuff that uses it heavily hard to follow.
21:23
<@Tarinaky>
That's what I mean.
21:23
< jerith>
Tarinaky: Like *args.
21:24
<@Tarinaky>
Okay. What's *args? >.>
21:24 * Tarinaky is such a newb.
21:24
< jerith>
It unpacks a sequence into individual params.
21:24 Kindamoody is now known as Kindamoody[zZz]
21:24
<@Tarinaky>
Ah. I think I get it.
21:24
<@Tarinaky>
So *[a,b,c] is a,b,c?
21:25
< jerith>
Basically.
21:25
< jerith>
But can only really use it in function params.
21:25
<@Tarinaky>
Yeah.
21:27
<@Tarinaky>
Err... Crap. What's the normal of the plane defined by 3 points?
21:27
< jerith>
You can do the same thing with dicts and **kwargs.
21:27
<@Tarinaky>
What's **kwargs?
21:28
<@Tarinaky>
Man. I am full of fail today >.<
21:28
< jerith>
Same as *args, but it turns keyword args into a dict.
21:28
< jerith>
Instead of positional args into a list.
21:29
<@Tarinaky>
I... don't understand.
21:29
<@Tarinaky>
It turns a list into a dict? Or it turns a dict into arguments?
21:29
< jerith>
In [1]: def foo(*args, **kw): ...: print args, kw ...:
21:29
< jerith>
In [2]: foo(1, 2, a=3, b=4)
21:29
< jerith>
(1, 2) {'a': 3, 'b': 4}
21:29
< jerith>
Ugh, formatting.
21:30
<@Tarinaky>
I thought '*' unwrapped?
21:30 * Tarinaky is really confused now >.<
21:31
< jerith>
It wraps and unwraps, depending on where it's used.
21:31
<@Tarinaky>
Ahh.
21:31
<@Tarinaky>
I see. So, basically... It's Magic :p
21:32
<@Tarinaky>
Oh!
21:32
<@Tarinaky>
I see!
21:32 * Tarinaky facepalms.
21:32
<@Tarinaky>
Clever!
21:33 * jerith glares at the pastebin, which is being slow.
21:33 Shield is now known as EvilDarkLord
21:33 Birds is now known as AnnoDomini
21:34
< jerith>
http://paste.ubuntu.com/766330/
21:34
< jerith>
Tarinaky: ^^^
21:35 * Tarinaky is kindof facepalming at his complete lack of ability with functional programming methods.
21:36
<@Tarinaky>
I aced that test, honest >.<
21:39 Shoat is now known as Ling
21:42
<@Tarinaky>
Okay... so...
21:42
<@Tarinaky>
map(reduce(lambda a,b: a-b), zip(pointList[2], pointList[1])) would perform vector subtraction right?
21:43
< Derakon>
...if you want to do vector operations, install numpy for serious.
21:43 * Tarinaky is currently wondering how easy numpy is to use now >.<
21:43
<@Tarinaky>
Is numpy not a builtin?
21:43
< jerith>
numpy's desigend for this stuff.
21:43
< Derakon>
No, it's not.
21:43
< jerith>
No.
21:43
< jerith>
For starters, it pulls in a bunch of linear algebra libraries and things.
21:44
< Derakon>
vec1 = numpy.array([1, 2, 3]); vec2 = numpy.array([4, 5, 6]); print vec2 - vec1 # prints "[3 3 3]"
21:44
<@Tarinaky>
I have no idea how to install it into this environment.
21:44
< jerith>
The usual ancient-and-reliable FORTRAN code that everyone uses for this stuff.
21:44
< jerith>
Are you using virtualenv?
21:44
<@Tarinaky>
I'm using the Windows dev distributable of panda3d.
21:44
< jerith>
Are you scripting panda3d in Python?
21:44
<@Tarinaky>
Yes.
21:45
<@Tarinaky>
Using the python that comes with panda3d
21:45
< jerith>
http://www.pyweek.org/a/243/ <-- relevant. :-P
21:45
< jerith>
Then you probably don't want to deal with numpy unless you really need it.
21:45
<@Tarinaky>
The ?Most annoying dependency? Award
21:46
< jerith>
Yes.
21:46
<@Tarinaky>
IDGI
21:46
< jerith>
To make that game work, I had to set up a Windows VM And install panda3d in it.
21:46
< jerith>
That's the panda3d logo. (Or was at the time, at least.)
21:47
<@Tarinaky>
Ouch
21:47
< jerith>
"41% respondents marked the game as not working."
21:48
< jerith>
Anyways, is it just 3-tuple points you're dealing with there?
21:48
<@Tarinaky>
Yes.
21:48
< jerith>
Are you getting them from or giving them to panda3d?
21:48
<@Tarinaky>
Giving them to.
21:48
< Derakon>
Jerith: supposedly you can make standalone executables with Panda3d, which would make distribution easier, but that'd probably be a lot bulkier than anything pyweek would want to distribute.
21:48
<@Tarinaky>
But the vector math isn't dependant on that.
21:48
<@Tarinaky>
The vector math is to do other cool shit.
21:49
< jerith>
Derakon: And probably Windows-only, which was the problem.
21:49
< Derakon>
Panda3d's available for OSX too, and presumably Linux as well.
21:49
< jerith>
Tarinaky: You might want to write a point3d class or something.
21:49
< jerith>
Derakon: Yes, but they didn't work.
21:49
< Derakon>
That said there might be OS-exclusive calls in it that this particular game was using? *shrug*
21:49
< Derakon>
Ah.
21:49
<@Tarinaky>
Does Python support operator overloading in the same way as c++?
21:50
< jerith>
Tarinaky: No, better than C++. :-)
21:50
<@Tarinaky>
How would I define what a + b meant for two objects?
21:51
< jerith>
http://docs.python.org/reference/datamodel.html#emulating-numeric-types
21:51
< jerith>
Basically, you'd implement __add__() and friends on your class.
21:53
<@Tarinaky>
Right.
22:00
<@Tarinaky>
Any advice on how to handle cross multiplication?
22:01
< jerith>
Carefully. ^.^
22:01
< jerith>
That's the kind of thing you probably want numpy for.
22:01
<@Tarinaky>
The joke is the only way I can remember to do it atm is through determinants.
22:01
<@Tarinaky>
As we've established... nah.
22:05 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
22:06 mode/#code [+qo Vornicus Vornicus] by ChanServ
22:07
<@Tarinaky>
Herp. I know there's a decorator that makes a method behave like an attribute but I can't remember what it is or where it is in the documentation.
22:13
<@Tarinaky>
Nm, think I found it.
22:13
< jerith>
@property
22:16
<@Tarinaky>
http://pastebin.com/XNuGDRYX << This is what I have. Look right?
22:17 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
22:17
< jerith>
You probably want explicit attributes for x, y and z.
22:18
<@Tarinaky>
I'm not sure I understand what you mean.
22:18
< jerith>
And you probably want your arithmetic operators to return a Vector3.
22:18
<@Tarinaky>
Ah.
22:19
<@Tarinaky>
How do I test to see if an argument is an object or a primitive?
22:20
<@Tarinaky>
No. Wait. Nm.
22:20
<@Tarinaky>
That'll cause too many headaches.
22:20
< jerith>
For what?
22:21
<@Tarinaky>
Because then 3*foo will be different to foo*3.
22:21
< jerith>
To accept both Vector3s and tuples?
22:21
< jerith>
__radd__()
22:21
<@Tarinaky>
TBH. This is turning into more work than I can be arsed with :)
22:21
< jerith>
__radd__()Yup.
22:21
< jerith>
Oops.
22:21
< jerith>
But you're learning a lot, aren't you?
22:22 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
22:25
<@Tarinaky>
http://pastebin.com/8CiMtkqM << Might be better I think >.>
22:25
<@Tarinaky>
Except with some returns put where they're supposed to be, lol.
22:25
< jerith>
Look at the operator module.
22:26
< jerith>
operator.add, operator.sub, etc.
22:26
< jerith>
It'll save you lambdas.
22:26
<@Tarinaky>
Ahh.
22:26
<@Tarinaky>
Meh. I don't mind lambdas.
22:38
<@Tarinaky>
Maybe I do :/
22:38
<@Tarinaky>
return map(reduce(lambda x,y: x-y), zip(a,b))
22:38
<@Tarinaky>
TypeError: reduce expected at least 2 arguments, got 1
22:39
< jerith>
Look at where your first ")" is.
22:40
< jerith>
Actually, that expression doesn't make much sense.
22:41
<@Tarinaky>
I have no idea what I'm doing. :/
22:41
<@Tarinaky>
return map(reduce(lambda x,y: x-y), zip(a,b))
22:41
<@Tarinaky>
TypeError: reduce expected at least 2 arguments, got 1
22:42
<@Tarinaky>
Err
22:42
<@Tarinaky>
GOD DAMN YOU COPTPASTE!
22:42
<@Tarinaky>
return map(operator.sub, zip(a,b))
22:42
<@Tarinaky>
TypeError: op_sub expected 2 arguments, got 1
22:42 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
22:45
< McMartin>
My guess is that it's treating zip(a,b) as a single argument that happens to be a tuple
22:45
< McMartin>
You need to, uh, uncurry operator.sub.
22:46
< McMartin>
I'm not sure if Python has a primitive for that, but:
22:46
< McMartin>
def uncurry(f):
22:46
< McMartin>
def result(x):
22:46
< McMartin>
(a, b) = x
22:46
< jerith>
reduce() takes a function to apply and a sequence to apply it to.
22:46
< celticminstrel>
What about map(operator.sub, *zip(a,b))?
22:47
< McMartin>
return f(a, b)
22:47
< McMartin>
return result
22:47
<@Tarinaky>
I hate zip and map :/
22:47
<@Tarinaky>
I fixed it by rewriting it as a list comprehension.
22:47
< McMartin>
As written, that map is poorly specified
22:47 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
22:47
< jerith>
I think map(operator.sub, zip(a, b)) is what you want.
22:48
< celticminstrel>
[Dec 10@5:46:56pm] celticminstrel: What about map(operator.sub, *zip(a,b))?
22:48
< McMartin>
That seems like it would hand map a hojillion arguments.
22:48
< jerith>
You don't want *zip().
22:49
< jerith>
Oh, I see.
22:49
< jerith>
You do need a lambda around that.
22:49
< jerith>
lambda a: a[0] - a[1]
22:50
< jerith>
expand = lambda op, tup: op(*tup)
22:51
< jerith>
Err, not quite. You want it to return a function.
22:51 * jerith is apparently too tired to follow this stuff clearly.
22:52 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
22:52
<@Tarinaky>
I'm having a bad day myself >.<
22:55
<@Tarinaky>
return math.sqrt(a^2+b^2+c^2)
22:55
<@Tarinaky>
ValueError: math domain error
22:55
<@Tarinaky>
Wut.
22:55
< celticminstrel>
Maybe a is not an integer.
22:55
< celticminstrel>
You can only XOR integers. :P
22:55
< celticminstrel>
(Try ** instead.)
22:55
< jerith>
a**2
22:56
< McMartin>
jerith: To took a draft at a generic uncurry above, though I haven't tested it
22:57
< jerith>
McMartin: You probably want something more like:
22:57
< jerith>
def uncurry(f):
22:57
<@Tarinaky>
Good news: the displacement is normal.
22:57
< jerith>
def result(args):
22:57
<@Tarinaky>
Bad news: The displacement is infinite.
22:58
< jerith>
return f(*args)
22:58
< celticminstrel>
?
22:58
< jerith>
return result
22:58
< jerith>
Except not interleaved with all the other conversation. :-P
22:58
< McMartin>
Ooh, that's better.
22:58
< celticminstrel>
:P
22:58
<@Tarinaky>
C-C-Combo breaker!
22:59
< McMartin>
If it's breakable, it's not a combo, just an attack string :colbert:
23:02 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
23:03
<@Tarinaky>
Good news: Displacement is now finite
23:03
<@Tarinaky>
Bad news: it's no longer normal.
23:06 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
23:06
<@Tarinaky>
Quick idiot/math check: http://pastebin.com/G38Xsws3
23:13 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
23:17 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
23:27
<@Tarinaky>
I FOUND THE PROBLEM!
23:27
<@Tarinaky>
I -am- an idiot.
23:28 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
23:35 AnnoDomini [annodomini@Nightstar-f7eedefa.80-203-17.nextgentel.com] has quit [[NS] Quit: Away!]
--- Log closed Sun Dec 11 00:00:03 2011
code logs -> 2011 -> Sat, 10 Dec 2011< code.20111209.log - code.20111211.log >

[ Latest log file ]