|
sorry it's worth noting that the explanation in my last post is still wrong, I... think. the conditionals are definitely being evaluated top-to-bottom, but something is traveling bottom-to-top; otherwise how did (WATER, ZEBRA) get into the innermost loop? functional programming is hard
|
# ? Jul 24, 2013 05:34 |
|
|
# ? Jun 6, 2024 06:20 |
|
if i were forced to reformat that code, i'd probably go withcode:
coffeetable fucked around with this message at 06:02 on Jul 24, 2013 |
# ? Jul 24, 2013 05:57 |
|
the most readable form doesn't use list comprehensions
|
# ? Jul 24, 2013 09:34 |
|
Python code:
|
# ? Jul 24, 2013 09:52 |
|
anyway here's the entire code:Python code:
here's one way to rewrite the function but it's pretty much the same thing qntm did and I didn't see his post before. Python code:
I don't think in this case the comprehension would be faster because he's only getting the first possible solution but even so it looks better to me. a similar brute force case where it would matter is in this problem. here's one of my first attempts before figuring the real trick: Python code:
Python code:
|
# ? Jul 24, 2013 14:11 |
|
This is definitely the most complex a single list comprehension should becode:
|
# ? Jul 24, 2013 17:01 |
|
Symbolic Butt posted:
|
# ? Jul 24, 2013 17:20 |
|
Can't you just use prolog
|
# ? Jul 24, 2013 17:21 |
|
oh hey that for-if ladder actually looks kinda cool when you put it this way *farts* I wonder if the zebra puzzle is one of those things that can be done particularly well in prolog from what I hear people say about it edit: what the gently caress FamDav
|
# ? Jul 24, 2013 17:24 |
|
Symbolic Butt posted:geez, so much indentation. speaking only for myself, there's no such thing as "too much indentation". i consider it a built-in requirement of the code, even when i'm not using python
|
# ? Jul 24, 2013 17:30 |
|
FamDav posted:Can't you just use prolog Symbolic Butt posted:I wonder if the zebra puzzle is one of those things that can be done particularly well in prolog from what I hear people say about it somebody light the tef-signal; i want to see what prolog would look like
|
# ? Jul 24, 2013 17:31 |
|
http://rosettacode.org/wiki/Zebra_puzzle#Prolog
|
# ? Jul 24, 2013 17:36 |
|
thanks now if only i can figure out what's actually happening (it definitely looks like this is something prolog is good at; much less convoluted than a lot of other languages)
|
# ? Jul 24, 2013 17:45 |
|
PleasingFungus posted:that is extremely silly, and certainly bad practice, but I can't bring myself to be upset about it. (the teddy in your av probably helps. ) holy gently caress dude i changed it to work this way (though it needs to be "OBJECTID in ({0})" because python 2.6 (that's what arc10 supports )) and it now takes 4 seconds to select 371000 features, instead of the hour and a half it took the original way this owns, thanks!
|
# ? Jul 24, 2013 19:59 |
|
dur posted:holy gently caress dude and here I thought I was just sperging about Proper Usage! super glad I could help.
|
# ? Jul 24, 2013 22:54 |
|
MeruFM posted:This is definitely the most complex a single list comprehension should be I don't understand. why include the conditional check if it's always going to return True?
|
# ? Jul 24, 2013 22:55 |
PleasingFungus posted:I don't understand. why include the conditional check if it's always going to return True?
|
|
# ? Jul 24, 2013 22:58 |
|
yospos a few months ago there was chatte about natural language unit test generators where you could go like add(2,4) should equal 6 butts("piss") should throw PoopException I don't remember the names of any of those generators and now I want to look at some of them and Google isn't helping
|
# ? Jul 25, 2013 02:18 |
|
unit tests is requirements with code inside -- a thing dumb babby p-langers say
|
# ? Jul 25, 2013 02:33 |
|
but if your unit tests have code inside, who's to say that code does what you meant? you need unit tests for it
|
# ? Jul 25, 2013 02:34 |
|
my unit tests are just generated boilerplate files, no code
|
# ? Jul 25, 2013 02:46 |
|
some day I will work in a company with a rich testing environment that day is not today
|
# ? Jul 25, 2013 03:19 |
|
PleasingFungus posted:some day I will work in a company with a rich testing environment NOPE
|
# ? Jul 25, 2013 03:21 |
|
uG posted:my unit tests are just generated boilerplate files, no code this except pretty much my whole project
|
# ? Jul 25, 2013 04:01 |
|
wait, you're the guy who claims that java/python/etc aren't "real programming languages" (as opposed to esoteric academic functional languages, aka, all functional languages) your opinions are a very strange mix.
|
# ? Jul 25, 2013 05:24 |
|
java is a real programming language although its subtyping is probably undecidable and it needs better support for first-class functions. algebraic datatypes would be nice too. so basically scala python is a joke
|
# ? Jul 25, 2013 05:29 |
|
The actual most important thing about a language is available libraries. This makes java/scala the best language for any purpose permitting a jvm
|
# ? Jul 25, 2013 05:44 |
|
PleasingFungus posted:some day I will work in a company with a rich testing environment
|
# ? Jul 25, 2013 05:44 |
|
Nomnom Cookie posted:The actual most important thing about a language is available libraries. This makes java/scala the best language for any purpose permitting a jvm Most of the popular java libs have c# versions or standard library equivalents these days.
|
# ? Jul 25, 2013 05:46 |
|
c# is better than java but not better than f#
|
# ? Jul 25, 2013 05:51 |
|
ruby's active record/active support/active model libraries are so good i cant imagine ever needing anything else
|
# ? Jul 25, 2013 06:00 |
|
Shaggar posted:Most of the popular java libs have c# versions or standard library equivalents these days. Lord prevent me from encountering a problem the C# stdlib can solve
|
# ? Jul 25, 2013 06:00 |
|
chumpchous posted:ruby's active record/active support/active model libraries are so good i cant imagine ever needing anything else Wow rails has static typing? People really aren't kidding when they say rails programmers don't know ruby
|
# ? Jul 25, 2013 06:01 |
|
chumpchous posted:ruby's active record/active support/active model libraries are so good i cant imagine ever needing anything else you still need C to do all the actual work for your ruby bindings if you want things to finish running in a timely fashion (probably not as you are using ruby)
|
# ? Jul 25, 2013 06:03 |
|
Nomnom Cookie posted:Lord prevent me from encountering a problem the C# stdlib can solve im struggling to think of a problem the c# stdlib can't solve
|
# ? Jul 25, 2013 06:21 |
|
uG posted:you still need C to do all the actual work this is true of everything
|
# ? Jul 25, 2013 06:21 |
|
ruby is a joke
|
# ? Jul 25, 2013 06:23 |
|
fun fact: all submissions for a cpan username get approved by a human, but only because nobody wants to update the centuries old code
|
# ? Jul 25, 2013 06:46 |
|
JewKiller 3000 posted:ruby is a joke sayin' that around here sure takes some monads
|
# ? Jul 25, 2013 07:04 |
|
|
# ? Jun 6, 2024 06:20 |
|
Bloody posted:im struggling to think of a problem the c# stdlib can't solve maybe i just hate programming then
|
# ? Jul 25, 2013 12:48 |