Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
brap
Aug 23, 2004

Grimey Drawer
reference semantics bitch

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=

fleshweasel posted:

reference semantics bitch

ya, no wannabe functional langs like scala, f#, etc stop you from mutating objects inside supposedly pure data structures.

haskell does, and i want to say that erlang might? even ocaml doesn't.

gonadic io fucked around with this message at 17:26 on Oct 9, 2015

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
python didn't seem to have any inbuilt way to flatten an arbitrarily nested list down to a single list which is dumb as poo poo

gonadic io
Feb 16, 2011

>>=

MALE SHOEGAZE posted:

python didn't seem to have any inbuilt way to flatten an arbitrarily nested list down to a single list which is dumb as poo poo

def flattenAll(xs): xs.map(flattenAll)

or whatever python's syntax is idk

do not call on infinite generators

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

MALE SHOEGAZE posted:

python didn't seem to have any inbuilt way to flatten an arbitrarily nested list down to a single list which is dumb as poo poo

tbf it's not like every language has that? I can only remember racket and erlang

I wonder how many people proposed it and got rejected

gonadic io
Feb 16, 2011

>>=
or i guess you only recurse if you're given a list, otherwise just return the element

this is a hylomorphism catamorphism i think

gonadic io fucked around with this message at 17:53 on Oct 9, 2015

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
don't start with the catamorphisms that are just monads in the theory of categories

Luigi Thirty
Apr 30, 2006

Emergency confection port.

monad only pawn in theory of categories

cinci zoo sniper
Mar 15, 2013




this is terrible programmer thread, please use existing words only

Soricidus
Oct 21, 2010
freedom-hating statist shill
this is a copromorphism in the category of postings

Shaggar
Apr 26, 2006
is it time for monad discussion???

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
https://mail.python.org/pipermail/python-dev/2006-September/068957.html

Soricidus
Oct 21, 2010
freedom-hating statist shill

ugh there they go again with the "it's easy to c&p soemthing from stack overflow so we won't put it in the standard library"

what happened to batteries included

gonadic io
Feb 16, 2011

>>=

Shaggar posted:

is it time for monad discussion???

dont moan at me

ryde
Sep 9, 2011

God I love young girls

Barnyard Protein posted:

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.

Not sure about your specific case, but you can define your own interface that has a method with three arguments and label it with @FunctionalInterface , and Java will then happily allow you to use lambda expressions for that interface.

jesus WEP
Oct 17, 2004


i hate monad chat because i assume everyone else is joking about not understanding them and im the only doofus who genuinely doesnt know wtf they are

Shaggar
Apr 26, 2006
Monads are whatever you need them to be

jesus WEP
Oct 17, 2004


i need them to be easy to explain toa total dumbfuck

Shaggar
Apr 26, 2006
If you understand a monad it ceases to exist

cinci zoo sniper
Mar 15, 2013




St Evan Echoes posted:

i hate monad chat because i assume everyone else is joking about not understanding them and im the only doofus who genuinely doesnt know wtf they are
don't worry you're in the right place, i have no idea what monads are either

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
A monad is a space burrito.

By which I mean it's just a type and three functions (map, join, and pure) that have particular signatures and respect the monad laws, plus some syntax sugar.

gonadic io
Feb 16, 2011

>>=
Picture three burritos on the edge of a cliff...

Bloody
Mar 3, 2013

Soricidus posted:

this is a copromorphism in the category of postings

lmao

gonadic io
Feb 16, 2011

>>=
For real though it's: can you define singleton and flatMap for your data structure. If yes than it's a monad if no then it's not.

lord of the files
Sep 4, 2012

not terribad programming related, but relevant because CEO asshat and firing an entire engineering team:

"Volkswagen's US CEO testified Thursday that the decision to use emissions cheating software was not made at the corporate level. Instead, it was 'software engineers who put this in for whatever reason,' Michael Horn told a congressional panel that is investigating the scandal."

http://arstechnica.com/tech-policy/2015/10/volkswagen-pulls-2016-diesel-lineup-from-us-market/

i rofl'd.

cinci zoo sniper
Mar 15, 2013




i was so triggered yesterday about this, ugh. they just were doing what they were told to :(

Shaggar
Apr 26, 2006
ah yes the classic german excuse

cinci zoo sniper
Mar 15, 2013




Shaggar posted:

ah yes the classic german excuse
see, goebbels was just talking about things, the peasants were the bad ones there

jesus WEP
Oct 17, 2004


Shaggar posted:

ah yes the classic german excuse

lord of the files
Sep 4, 2012

i wouldn't say triggered, i was loving pissed. i am wondering about the laws there about that sort of thing, and what if some asshat pulls this in the united states and what laws could protect the engineering team.

Shaggar
Apr 26, 2006
there are whistleblower laws but lots of times whistleblowing leads to you being arrested as a terrorist.

since its vw they could probably have told the EPA and been fine cause its not like its ford or chevy.

lord of the files
Sep 4, 2012

Shaggar posted:

there are whistleblower laws but lots of times whistleblowing leads to you being arrested as a terrorist.

since its vw they could probably have told the EPA and been fine cause its not like its ford or chevy.

whistleblowing = time to shop for estates in moscow?

Shaggar
Apr 26, 2006
only if putin doesn't have a stake in the entity you're exposing

gonadic io
Feb 16, 2011

>>=

Shaggar posted:

only if putin doesn't have a stake in the entity you're exposing

Then you flee to the us

Soricidus
Oct 21, 2010
freedom-hating statist shill

Nitrocat posted:

i wouldn't say triggered, i was loving pissed. i am wondering about the laws there about that sort of thing, and what if some asshat pulls this in the united states and what laws could protect the engineering team.

lol

yes, the usa definitely has laws to prevent employees being hosed over by their corporate masters, that's exactly what the last few decades of capitalist deregulation have produced

pepito sanchez
Apr 3, 2004
I'm not mexican
firing software engineering teams makes your stock go up tho. nuremberg defense continues to fail

qntm
Jun 17, 2009

MALE SHOEGAZE posted:

python didn't seem to have any inbuilt way to flatten an arbitrarily nested list down to a single list which is dumb as poo poo

if you tried this on a string you'd get a stack overflow :q:

lord of the files
Sep 4, 2012

gonadic io posted:

ya, no wannabe functional langs like scala, f#, etc stop you from mutating objects inside supposedly pure data structures.

haskell does, and i want to say that erlang might? even ocaml doesn't.

python's documentation on this says cahins.from_iterable is the preferred way:

http://docs.python.org/2.7/library/functions.html#sum
x = [[1, 2], [3, 4], [5, 6]]
list(itertools.chain.from_iterable(x))

which is the equivilent of saying [ for x for x in x for x in x].

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

LeftistMuslimObama posted:

I dug up the "text adventure" I wrote in TurboPascal in 10th grade. I didn't know anything about non-array data structures or about loading from/saving to files so the entire game map is encoded as several hundred methods. Each method does the following:
1)Print a description of where you're standing
2)Perform a random number generation to determine if you are attacked by a monster, initiate battle engine if so.
3)State which directions you can go in, prompt for input.

Each method then simply called the method that represented the "cell" in the direction you wanted to go in. The map was close to 500x500 cells (I drew it in Excel to use as a reference while I coded). Also no validation of any input at any point. I spend close to 50 hours over thanksgiving weekend coding the stupid thing, and the file got so big that I exceeded the maximum line count TurboPascal for Windows could handle and had to switch to Borlean's shareware DOS pascal IDE (I hadn't learned about header files yet either).

I found the source code to this in an old dropbox:
http://pastebin.com/Qvg91WBn

Adbot
ADBOT LOVES YOU

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Soricidus posted:

this is a copromorphism in the category of postings

  • Locked thread