|
list comprehensions are really confusing to look at but once you get them they are insanely usefulcode:
|
# ? Oct 9, 2015 06:07 |
|
|
# ? May 23, 2024 15:40 |
|
Bloody posted:it probably isn't hard in python but I do not know how to do things result = [function(e[1]) for e in collection if e[0] == 2]
|
# ? Oct 9, 2015 06:26 |
|
or if its a big collection it might be better to do result = (function(e[1]) for e in collection if e[0] == 2) which gives you a lazily evaluated generator instead of a strictly evaluated list
|
# ? Oct 9, 2015 06:29 |
|
i really just do not like python
|
# ? Oct 9, 2015 06:34 |
|
or if you wanna use all the filter and map stuff like you were thinking: result = map(lambda e: function(e[1]), filter(lambda e: e[0] == 2, collection))
|
# ? Oct 9, 2015 06:39 |
|
but i think if you want to make guido happy, the elegant pythonic way would be:code:
|
# ? Oct 9, 2015 06:42 |
|
python is weird. i had to convery some numpy python code to java this past week and gosh was it weird. i think it was a method called "copyto" where the first parameter was an array destination, the second was an array source, and the third was a predicate that operated on yet another array. i couldn't figure out how to handle that third array in a way that i was happy with. i had to abandon nice java8 functional interfaces and iterate through the arrays like some kind of idiot.
|
# ? Oct 9, 2015 06:45 |
|
Barnyard Protein posted:python is weird. i had to convery some numpy python code to java this past week and gosh was it weird. i think it was a method called "copyto" where the first parameter was an array destination, the second was an array source, and the third was a predicate that operated on yet another array. i couldn't figure out how to handle that third array in a way that i was happy with. i had to abandon nice java8 functional interfaces and iterate through the arrays like some kind of idiot. you should use haskell until you figure out how to do anything with functional interfaces instead of iteration
|
# ? Oct 9, 2015 06:49 |
|
fart simpson posted:you should use haskell until you figure out how to do anything with functional interfaces instead of iteration i could have done it in a nice way with a scheme or racket, a smarter person maybe could have done it better with java8. but java8's functional interfaces don't allow for functions with more that two inputs.
|
# ? Oct 9, 2015 06:55 |
|
its really easy to bang out things as you think them up and its modules are more dependable and air-gapped than ruby so i like it a lot but i hardly ever write anything thats more than two hundred lines long so i dont ever have to deal with the serious problems with plangs
|
# ? Oct 9, 2015 06:56 |
|
so just zip inputs together and unzip them as needed e: re: barnyard protein
|
# ? Oct 9, 2015 06:56 |
|
fart simpson posted:or if its a big collection it might be better to do This is what most people should be using list comprehension is just the most common use case of mapfilter
|
# ? Oct 9, 2015 06:57 |
|
Shaggar posted:why would you use scala when you could just use java? Lol no thanks And as for groovy: gently caress no. Having to add a few extra type sigs isn't the end of the world and I like most of the rest of scala.
|
# ? Oct 9, 2015 06:58 |
|
fart simpson posted:so just zip inputs together and unzip them as needed i just googled that and yes okay you have convinced me to learn haskell, hot drat. i wonder what other stupid poo poo i've been doing to compensate for not knowing the right way to do things!
|
# ? Oct 9, 2015 06:59 |
|
Barnyard Protein posted:i just googled that and yes okay you have convinced me to learn haskell, hot drat. i wonder what other stupid poo poo i've been doing to compensate for not knowing the right way to do things! haskell functions only accept 1 argument. everything else is built upon that
|
# ? Oct 9, 2015 07:00 |
|
Luigi Thirty posted:No USER AIDS. I tried. in sdl.c around line 213 there's a block: code:
which should actually be: code:
tweaking that was enough to boot to the full Lisp environment on my Linux box
|
# ? Oct 9, 2015 07:31 |
|
Luigi Thirty posted:
it's just rms's maintenance work on others' design and implementation, he didn't even come up with the "lisp as extension/implementation language for emacs" idea even gnu emacs isn't original to rms, I gather it started as a hack on gosmacs and then he had to replace that code ("oops")
|
# ? Oct 9, 2015 07:36 |
|
Ralith posted:Doesn't CLIM still sort of work on modern Common Lisp implementations? I think you can get CLIM with the commercial implementations I've been able to make McCLIM work on Linux (but not OS X) under SBCL, its example listener is bare-bones but does actually have some of the Symbolics features (like clicking on any compatible object in the transcript to provide input to the command line)
|
# ? Oct 9, 2015 07:39 |
|
Barnyard Protein posted:but java8's functional interfaces don't allow for functions with more that two inputs.
|
# ? Oct 9, 2015 07:43 |
|
just use the Common Lisp LOOP macro, it can do anything it's the zombo.com of iteration
|
# ? Oct 9, 2015 07:47 |
|
NihilCredo posted:lmao what why https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
|
# ? Oct 9, 2015 07:53 |
|
Corla Plankun posted:the itertools module's only valid use case is making stack overflow answers long enough to submit itertools.product is good and useful but I hate the way half the itertools documentation is taken up with providing source code to useful functions that you have to c&p to use because they didn't put them in the actual module, why the gently caress do people do that
|
# ? Oct 9, 2015 11:30 |
|
MALE SHOEGAZE posted:i really just do not like python its a bad language
|
# ? Oct 9, 2015 14:28 |
|
I like Python. but I am a bad programmer too sooooo
|
# ? Oct 9, 2015 14:33 |
|
fart simpson posted:but i think if you want to make guido happy, the elegant pythonic way would be: if you're going this path then use .append Python code:
|
# ? Oct 9, 2015 14:37 |
|
i want to know why. tell me
|
# ? Oct 9, 2015 14:39 |
Elder Postsman posted:I like Python. but I am a bad programmer too sooooo
|
|
# ? Oct 9, 2015 14:42 |
|
also indices are grosscode:
code:
Symbolic Butt fucked around with this message at 14:52 on Oct 9, 2015 |
# ? Oct 9, 2015 14:45 |
|
pythons functional stuff looks yucky
|
# ? Oct 9, 2015 14:49 |
fart simpson posted:i want to know why. tell me if you do .append, you put add b as last element of c cinci zoo sniper fucked around with this message at 14:53 on Oct 9, 2015 |
|
# ? Oct 9, 2015 14:50 |
|
Bloody posted:pythons functional stuff looks yucky
|
# ? Oct 9, 2015 14:51 |
|
kalstrams posted:i just woke up so don't yell much please but c += b is c = c + b, and when your c is array but your b is not an iterable thing of same dimension, python just calls you a doofus and stops working oh yeah. i belong in this thread e: so obviously the answer is to do result += [function(e[1])]
|
# ? Oct 9, 2015 15:01 |
|
kalstrams posted:i just woke up so don't yell much please but c += b is c = c + b, and when your c is array but your b is not an iterable thing of same dimension, python just calls you a doofus and stops working there was a discussion about this += poo poo earlier on this thread I think, I'll search for it later but the gist is 1. it's dumb slow because 2. += calls .__iadd__ so sometimes a += b is NOT equivalent to a = a + b and this can bite your rear end it's like a whole class of potential bugs exclusive to python because of this gotcha and variations of it. go with .append and .extend basically only use + for number things, for everything else it's probably bad
|
# ? Oct 9, 2015 15:10 |
|
lol python is bad
|
# ? Oct 9, 2015 15:11 |
|
eschaton posted:it's just rms's maintenance work on others' design and implementation, he didn't even come up with the "lisp as extension/implementation language for emacs" idea I know but I can never pass up a good rms joke much like he can never pass up foot fungus
|
# ? Oct 9, 2015 15:19 |
Shaggar posted:lol python is bad
|
|
# ? Oct 9, 2015 15:23 |
|
python is mostly good also numpy has its own idioms so the better way to do that would probably be using an index mask instead of forcing comprehensions/itertools whatever pseudo-functional shenanigans. gotta go full vector programming
|
# ? Oct 9, 2015 15:39 |
|
code:
|
# ? Oct 9, 2015 16:14 |
|
if tuples are immutable, why can you mutate the data inside them?
|
# ? Oct 9, 2015 16:50 |
|
|
# ? May 23, 2024 15:40 |
fart simpson posted:if tuples are immutable, why can you mutate the data inside them? e2: uhh, looks like tuple contains reference to object, not objects, so you caan gently caress with objects but not with references? cinci zoo sniper fucked around with this message at 17:04 on Oct 9, 2015 |
|
# ? Oct 9, 2015 17:00 |