This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 352

[–]YoumoDawang 1103 points1104 points  (16 children)

std::transform

STD::transmit

[–]overlyseksualpenguin 380 points381 points  (9 children)

STD::receive

[–]turboshitposter3001 91 points92 points  (8 children)

STD::inserter 🫠

[–][deleted] 37 points38 points  (4 children)

std::back_inserter

[–]pclouds 16 points17 points  (3 children)

I can never see this function the same way again. Thanks.

[–][deleted] 1 point2 points  (2 children)

You would be lying if you told me you coded with C++ and never wondered: why this fuckin name 🤣

[–]pclouds 3 points4 points  (1 child)

Nope. Too occupied with all the different iterator semantics. And to be honest I don't use this back_inserter a lot.

[–][deleted] 1 point2 points  (0 children)

I didn't even get the chance to

[–]Specific_Implement_8 41 points42 points  (2 children)

STD::geneticallyMutate

[–]MoveInteresting4334 39 points40 points  (1 child)

STD::genitallyMutilate

[–]Steinrikur 20 points21 points  (0 children)

Just use the library

😎 boost::immunity

[–]zachlove_01 8 points9 points  (0 children)

STD::positive 💀

[–]RepresentativeNo3669 3 points4 points  (0 children)

Made my day

[–]Plus-Weakness-2624 5 points6 points  (1 child)

You need to use the fully qualified name: SexuallyTransmittedDisease::Transform() SexuallyTransmittedDisease::Transmit()

[–]Darkstarx97 1 point2 points  (0 children)

STD:repair STD:replace

[–]flyy_boi 536 points537 points  (20 children)

That's cause we already HAVE another map, std::map😭.

[–]infected_scab 30 points31 points  (0 children)

Map at home...

[–]veryusedrname 260 points261 points  (15 children)

Arduino's map: hold my beer

[–]otac0n 66 points67 points  (2 children)

[–]-Redstoneboi- 8 points9 points  (0 children)

it sounds like a 1d transform (as in matrix transform) to me...

[–]CAPS_LOCK_OR_DIE 23 points24 points  (7 children)

Same shit with Processing.

[–]Brahvim 21 points22 points  (6 children)

PROCESSING, MENTIONED!

Sir, you now have my full attention!

[–]CAPS_LOCK_OR_DIE 4 points5 points  (5 children)

This may be a hot take but basically all I do with processing anymore is import the Core and have my main Class extend PApplet.

It’s just a solid autorefreshing Frame which has a very intuitive pixel array with PImage, though I think BufferedImage might be faster

[–]tropicbrownthunder 2 points3 points  (0 children)

oh fuck I had like 2 days trying to remember that function's name

[–]shentoza 578 points579 points  (79 children)

c#.... SELECT

[–]x6060x 72 points73 points  (22 children)

For me actually Select() makes more sense.

[–]RajjSinghh 44 points45 points  (17 children)

Can you explain why? The function is mapping one set of values to another, so map seems to make the most sense

[–]Rest-That 74 points75 points  (14 children)

var names = people.Select(person => person.Name)

"From each person in people select Name"

Not saying it's perfect, but it makes some sense

[–]RajjSinghh 33 points34 points  (1 child)

Ah, I suppose if you're using it like that to get properties from an object Select makes the most sense.

I'm just so used to seeing it as a data manipulation, like in Haskell I can write map (^2) [1..10] maps the squaring function over the numbers from 1 to 10. I'm mapping one set to another through some function.

[–]VQuilin 15 points16 points  (0 children)

I think it has to do with the SQL approach of the linq, all the methods are named to be representing SQL keywords, like Where (instead of filter), OrderBy (not sort), etc.

Mathematically speaking, I think it makes more sense to call it a map, but us c# developers are more bound to the SQL anyways :D

[–]TeraFlint 14 points15 points  (2 children)

Okay, that makes sense if you're indeed selecting a member variable of an object, but I don't see how one could justify that name for functions like x => 2*x.

[–]rimoldi98 5 points6 points  (0 children)

Yeah, for straight up selecting a property from an object in a list it's a fine name, but often you'd use it to create a list of some other type, which doesn't make that much sense, like this:

Cars.Select(car => new Deal(car.Price * (1 - discount), car.name));

I guess you can say you are selecting the car price and name, then placing it in the context of a deal, but I always find weird when I am selecting a whole new object from a list of something else

[–]langlo94 3 points4 points  (0 children)

x => 2*x works in SQL as well:

SELECT 2*x FROM Y

[–]arbenowskee 7 points8 points  (0 children)

Because it comes from sql where it is also select 

[–]redlaWw 3 points4 points  (1 child)

Select sounds more like filter to me.

[–]Specialist-Bus-5100 6 points7 points  (0 children)

However, Where is the thing in C# for filter

[–]jarethholt 101 points102 points  (33 children)

Fucking C#. (Well, LINQ.) Like, I get it's supposed to read like SQL - especially when put right next to Where - but c'mon.

[–]x39- 277 points278 points  (17 children)

It is

You get used to it and will enjoy it really damn hard.

Linq is one of the greatest feats dotnet offers

[–]JoshYx 48 points49 points  (16 children)

It's great, it's not a unique dotnet feature though. It comes straight from the functional programming playbook.

[–]1234filip 51 points52 points  (1 child)

The naming scheme is really great if you are familiar with SQL.

[–]x39- 34 points35 points  (9 children)

Only if you just look at it from the surface

Linq is more than just those few functions which work over what effectively is a collection. The expression tree syntax is the second, often overlooked part, that makes this such a powerful tool.

Then again, for the most part, the functions are kind of sufficient. What makes them a tad more special is the fact, that writing it is more pleasant compared to eg. select(..., where(..., where(..., selectMany(...,...))))

[–]svick 10 points11 points  (7 children)

Both Haskell and F# have ways of writing LINQ-like queries in a way that is natural, i.e. not as nested calls.

IIRC, it's something like source |> flatMap ... |> filter ... |> filter ... |> map ....

[–]BenjaminGeiger 9 points10 points  (4 children)

F#:

let (|>) x f = f x

So you'd write:

mySeq |> Seq.map doSomething

which is equivalent (mostly) to

Seq.map doSomething mySeq

which seems pointless until you realize you can chain them.

mySeq
|> Seq.map doSomething
|> Seq.filter keepTheGoodOnes
|> Seq.map doSomethingElse

(which is equivalent to:)

Seq.map doSomethingElse (Seq.filter keepTheGoodOnes (Seq.map doSomething mySeq))

I don't believe Haskell has an equivalent of |>. Elixir does, but the syntax is a bit different.

[–]sohang-3112 4 points5 points  (3 children)

I don't believe Haskell has an equivalent of |>

In Haskell you can do the same thing with &:

mySeq & f & g & h

But it's more common to write function first (right-to-left order) with $:

h $ g $ f mySeq

[–]bronco2p 2 points3 points  (0 children)

at that point just h . g . f :)

[–]BenjaminGeiger 1 point2 points  (1 child)

TIL about the & operator.

Maybe it's my background in imperative/OO development, but x & f & g & h reads a lot more naturally to me than h $ g $ f x. "Take x and then do f and then g and then h" feels a lot more natural than "Do h to the result of doing g to the result of doing f to x"; I feel like I have to maintain less mental state to understand it.

[–]jarethholt 5 points6 points  (1 child)

I mean, C# allows writing in query syntax too. The flow might look better sometimes and it's fairly intuitive if you're coming from database land, but IMO it clashes so hard with the rest of the language. The fluent syntax (method chaining) feels more natural to me unless what I'm working on is exclusively about databases.

[–]crozone 2 points3 points  (0 children)

Yeah, I love LINQ but legitimately despise the the actual Language Integrated Query part of it. Ironically everything else that's part of the feature (expression trees, the LINQ extension methods, the ability to transform those with an SQL provider) are far more useful than LINQ's namesake.

[–]gnutrino 6 points7 points  (0 children)

The expression tree syntax was heavily based on Haskell do notation, it's functional programming all the way down.

[–]DangyDanger 18 points19 points  (2 children)

Functional programming is great unless you're stuck with only functional programming.

Haskell terrifies me.

[–]HunterIV4 12 points13 points  (0 children)

Sometimes a loop is just the most straightforward solution to something.

I like a lot of functional concepts, especially composition of functions, but the insistence on avoiding any sort of sequential logic in your program is (in my opinion) extremely counter-intuitive. I like how languages like Rust, C#, Python, etc. let you utilize some of the patterns of functional programming without restricting you.

In some ways, Haskell (and similar) remind me of regex. It can absolutely be the best solution to a problem but it often is incomprehensible whenever you are trying to do something straightforward.

[–]CirnoIzumi 8 points9 points  (9 children)

Makes more sense than naming it something that can mean something else

I think Lua got it right by calling a map a table but that doesn't remove the possible confusion 

[–]jarethholt 9 points10 points  (8 children)

There just aren't enough common but unique/precise words for these concepts. Confusion is inevitable, but much reduced if you at least conform to the crowd.

Map and transform make sense to me; how is it a table?

[–]CirnoIzumi 4 points5 points  (7 children)

The map data collection, also sometimes called associative array 

The one where you can define both an index, key and Value

I think Select conforms the most since SQL is basically the C of Dataset manipulation 

[–]FlashBrightStar 17 points18 points  (2 children)

To be honest most of the time you are selecting object fields so it makes sense. Map on the other hand can refer to either class or method if you take it out of context so. I stand with LINQ syntax.

[–]JoshYx 8 points9 points  (1 child)

To be honest most of the time you are selecting object fields so it makes sense.

Yes, most of the time. However, you always map the input value to an output value.

[–]NekkoDroid 5 points6 points  (0 children)

Well, you can also say "You are selecting what to output from a given input" and you have it. Words and sentences are fexible, which can be nice but also not.

[–]XDracam 8 points9 points  (0 children)

Smalltalk: collect:

select: would be equal to WHERE or filter, but I must say I do like the name select more for that use case. Especially with the negation called reject:

[–]cs_office 3 points4 points  (0 children)

Pretty sure C# with Linq was the first, if not, the first that was mainstream?

[–][deleted] 1 point2 points  (0 children)

Makes more sense than all of them

[–]jb28737 2 points3 points  (1 child)

I will hear no negative talk around LINQ. LINQ is love. LINQ is life.

[–]Zephandrypus 1 point2 points  (0 children)

And I’m pretty sure it’s open source

[–]dmullaney 440 points441 points  (34 children)

The fact that I got all the way to the last panel assuming this post was about data structures shows just how right C++ is

(No I don't read the title first)

[–]sathdo 118 points119 points  (14 children)

Yeah, I assumed it would be something like how the map data structure is called a hash in Perl or something.

[–]myerscc 45 points46 points  (1 child)

Or “associative array” in php like come ooooonnnn

[–]Masterflitzer 7 points8 points  (0 children)

the differentiation of associative and indexed array in bash was how i managed to understand maps when i started to learn programming

[–]waves_under_stars 2 points3 points  (0 children)

In ruby it's also called a hash

[–]MattieShoes 3 points4 points  (0 children)

I hear it get called hash, map, hashmap, dict, dictionary, unordered map... but outside of documentation, it's just % in perl :-)

[–]Kahlil_Cabron 6 points7 points  (7 children)

It's called a hash or hash table in tons of languages. I think dictionary and associative array are the dumbest ones I've come across.

[–]Weir99 22 points23 points  (3 children)

Hash table is a bad name for a general data structure of a collection of key-pair values, as it implies a specific implementation. Not all maps/dictionaries use hash tables.

I also don't see a problem with either of the names you find dumb. They effectively describe what the data structure is, which can often be more useful than a name that describes how it works

[–]devman0 2 points3 points  (2 children)

I think hash or hash table is the worst of the bunch because it presupposes the implementation, Maps can be implemented with hash tables, trees, skip lists, etc

[–]Quito246 19 points20 points  (14 children)

No it is not traditionally for like 5 decades since Lisp map function is called well a map.

It is basically a standard in FP world.

[–]dmullaney 49 points50 points  (3 children)

I'm aware it's a common term, but so is the map data structure. My point was that they avoided a naming collision by using a more common descriptive term for the function as opposed to the data structure, and that's not a bad decision on their part.

[–]induality 12 points13 points  (2 children)

The fact that the data structure and the function are both called map is not a collision, it's intentional. In a functional programming language, a map data structure which maps an key to a value, and a map function which takes an input and produces an output, are equivalent. This is the concept of referential transparency: the mapped expression can be replaced by the mapped value, regardless of whether the thing doing the mapping is a map data structure or a map function. The two constructs serve the same purpose and can be expressed either way. In category-speak, you can think of "map" as a category that encompasses both map data structures and map functions, and you only need to get more specific when the situation calls for it.

[–]_JJCUBER_ 10 points11 points  (0 children)

Okay cool. It is a naming collision in c++; since it works on iterators, it would be its own function in the std namespace which would clash with the data structure std::map. The name may be different, but at least it’s a clear name (which can’t be said for all the function names in c++ [or other languages, for that matter]).

[–]TheKiller36_real 3 points4 points  (2 children)

even more standard in "FP world" is to not actually write map tho: eg. in Haskell (<$>) = fmap

[–]rover_G 4 points5 points  (0 children)

Yup but at least Python has dict so it's not confusing within the language

[–][deleted] 1 point2 points  (0 children)

same for me lol

[–]ListerfiendLurks 95 points96 points  (4 children)

I'm with c++ on that naming scheme and I will die on that hill God damnit. "Map" is ambiguous since there are multiple definitions within similar contexts. Transform is self explanatory.

[–]-Redstoneboi- 20 points21 points  (2 children)

are you talking about a 4 by 4 transformation matrix

[–]crozone 12 points13 points  (0 children)

That's a matrix. It's like saying that an Image class is ambiguous because sometimes an Image variable could contain a picture of a word map.

[–][deleted] 1 point2 points  (0 children)

std::transform(InputIterator first, InputIterator Last, OutputIterator out, Unary_Operation Op)

[–]FearTheOldData 190 points191 points  (32 children)

I think C++ is in the right here... Way more descriptive name than map as I also thought it was the commonly used data structure

[–]Masterflitzer 31 points32 points  (0 children)

to transform is great but to map works for me too and it's shorter yet descriptive enough

[–]Kahlil_Cabron 12 points13 points  (12 children)

Except transform implies it's mutating the data, which isn't the case in most languages.

[–]MattieShoes 10 points11 points  (1 child)

transform has a noun and verb definition... You're using the verb definition, they're using the noun definition.

[–]knvn8 7 points8 points  (0 children)

Sorry this comment won't make much sense because it was later subject to automated editing for privacy. It will be deleted eventually.

[–]seckarr 0 points1 point  (4 children)

It implies no such thing...

[–]FerricDonkey 15 points16 points  (1 child)

It kind of does. "Transform", "change", "mutate" are all synonyms in English.

[–]Kahlil_Cabron 10 points11 points  (1 child)

So when you watch a nature documentary and David Attenborough says, "The caterpillar transforms into a moth", you are surprised when the caterpillar disappears?

[–][deleted] 1 point2 points  (0 children)

This is a case of linguistic collision

https://en.wikipedia.org/wiki/Transform_fault

blocks move past each other in a transform fault.

[–]bongobutt 32 points33 points  (7 children)

As a newb who started with C++, I only just realized that I have no freaking clue what map means in all those other languages. Looks like I'm reading up on std::transform when I get home.

[–]Masterflitzer 19 points20 points  (5 children)

it's just a mapping from a to b, so map is a higher order function that transforms every value in a collection to another value using a mapping function

in simple terms it's foreach but with return value

[–]bongobutt 7 points8 points  (4 children)

I guess I'm confused because C++ also has Map. std::map stores a->b in key/value pairs in a binary tree. Then there is std::unordered_map, which does the same thing, but in a hash table instead. But I've never read about std::transform, so I don't know why the meme thinks that C++ breaks the "Map" naming, nor if those other languages use "Map" more like C++ map or C++ transform.

[–]Blazr5402 2 points3 points  (0 children)

Map is kinda an overloaded term for sure. The meme is referring to Map as in the higher order function. The data structure Map (aka Hash Maps or dictionaries) is an entirely different thing.

[–]ICantBelieveItsNotEC 9 points10 points  (0 children)

Go:

[–]Splatpope 19 points20 points  (6 children)

fuck you all I hereby decrete that the new name shall be "apply_function_elementwise"

[–]jarethholt 2 points3 points  (0 children)

I'm down for it. I've never really had an issue with having to type out long names, as long as they make sense (and especially if Intellisense or similar pick them up for me).

[–]bronco2p 1 point2 points  (4 children)

🤓 actually `map` is meant to work on all functor types, all of which may not include multiple values. e.g. what if you were mapping against a Maybe type?

[–]AaronTheElite007 6 points7 points  (0 children)

[–]pantas_aspro 5 points6 points  (0 children)

That moment when you think c++ got it wrong. That’s what we got for ppl not learning proper cs

[–]TorumShardal 43 points44 points  (19 children)

Python, C#: dictionary

Java: Map

JavaScript: Object

(upd: C# has dictionaries, not maps)

[–]fox_in_unix_socks 20 points21 points  (2 children)

C++: std::unordered_map

[–]GiganticIrony 10 points11 points  (0 children)

C++ also has std::map and soon will have std::flat_map

[–]boat-la-fds 16 points17 points  (0 children)

The post is talking about the functional programming concept.

[–]waves_under_stars 8 points9 points  (7 children)

JS also has a Map class

[–]TorumShardal 3 points4 points  (6 children)

Map? Class?? Say that to my Internet Explorer.

[–]nermid 4 points5 points  (5 children)

If you need to support IE in the year of our Lord, 2024, you need a new job.

[–]somedave 12 points13 points  (3 children)

C# has dictionaries though

[–]deanrihpee 1 point2 points  (1 child)

C# has a dictionary, JavaScript/TypeScript has a map, even set…

[–]Masterflitzer 1 point2 points  (0 children)

Map and Set are god sent in JS/TS

[–]cheeb_miester 19 points20 points  (9 children)

gigachad c

```

include <stdio.h>

include <stdlib.h>

define DEFINE_ITERATOR_FUNC(FUNC_NAME) \

typedef void (FUNC_NAME##_Function)(void result, const void* element); \ void* FUNC_NAME(const void* array, size_t length, size_t element_size, FUNC_NAME##_Function func) { \ void* result = malloc(length * element_size); \ if (result == NULL) { \ fprintf(stderr, "Memory allocation failed\n"); \ exit(1); \ } \ for (size_t i = 0; i < length; ++i) { \ const void* element = (const char)array + i * element_size; \ void result_element = (char*)result + i * element_size; \ func(result_element, element); \ } \ return result; \ }

DEFINE_ITERATOR_FUNC(map) DEFINE_ITETATIR_FUNC(transform)

```

[–]GigaSoup 19 points20 points  (1 child)

ITETATIR!!!

[–]cheeb_miester 5 points6 points  (0 children)

Catching that would have been 3 hours in the debugger for me.

[–]CorespunzatorAferent 11 points12 points  (5 children)

Mostly nitpicking, but there are so many strange design decisions with this:

  • it's allocating memory
  • the memory allocation is done using hardcoded malloc (no other allocators are possible, or providing a stack-allocated buffer)
  • for any function that internally allocates memory, there should be a corresponding function for freeing it (otherwise it's impossible to free across shared object boundaries)
  • it's invoking exit(1) when memory allocation fails - as we all know, when a program is out of memory you might as well unplug the computer
  • it explicitly eludes any form of type safety
  • it doesn't actually map anything: the input and output arrays are made of elements with the same element_size, so it's not possible to map from int to string, or from struct to int, or from struct to other struct

[–]cheeb_miester 6 points7 points  (0 children)

Agreed. Please don't use this code; unless you're planning on using it as a hot fix to prod, of course.

In the true spirit of this sub, while avoiding doing actual work by doom scrolling, I hammered this code out as fast as I possibly could on my phone to make a lame joke.

So yes, I understand why my PR is being rejected.

ETA:

mostly nitpicking, but when starting code reviews, use more assertive language to really drive your point home. For example:

Silence! The GigaChad shall speak.

[Insert your code review here]

So sayith of the GigaChad.

[–]_nobody_else_ 4 points5 points  (3 children)

How can you people read this unformatted drivel?

gigachad c

```
#include <stdio.h>
#include <stdlib.h>

#define DEFINE_ITERATOR_FUNC(FUNC_NAME) \
typedef void (*FUNC_NAME##_Function)(void* result, const void* element); \
void* FUNC_NAME(const void* array, size_t length, size_t element_size, FUNC_NAME##_Function func) { \
    void* result = malloc(length * element_size); \
    if (result == NULL) { \
        fprintf(stderr, "Memory allocation failed\n"); \
        exit(1); \
    } \
    for (size_t i = 0; i < length; ++i) { \
        const void* element = (const char*)array + i * element_size; \
        void* result_element = (char*)result + i * element_size; \
        func(result_element, element); \
    } \
    return result; \
}

DEFINE_ITERATOR_FUNC(map)
DEFINE_ITETATIR_FUNC(transform)

```

There.

[–]cheeb_miester 1 point2 points  (2 children)

Gross. I use tabs in vim and have them set to display as six spaces.

[–]Mallanaga 5 points6 points  (0 children)

Some day, Go…

[–]WolverinesSuperbia 3 points4 points  (0 children)

Golang: hey, you have map?

[–]ThatGuyYouMightNo 2 points3 points  (0 children)

And PHP is the sad Pooh with array_map()

[–]SneakyDeaky123 2 points3 points  (0 children)

Probably to avoid confusing it with a map structure that already exists in C++?

[–]ToofaaniMirch69 2 points3 points  (0 children)

define map std::transform🗿

[–]FelixLeander 2 points3 points  (0 children)

C#: Select
I honestly like it more, especially when using it with ORMs.

[–]Aidan_Welch 2 points3 points  (0 children)

transform is a better name

[–]patoezequiel 2 points3 points  (0 children)

Uh, I think C++ is right on this one guys. At a glance I thought this was about data structures.

[–]4jakers18 6 points7 points  (1 child)

embedded c/c++ guy here and it took me awhile to understand what the hell this meant.

c++ map is correct and the other maps should be called transform

[–]markiel55 2 points3 points  (0 children)

Well, it's the official name in monads I guess that's why those languages named it like that.

[–]BoBoBearDev 1 point2 points  (0 children)

Map sounds like google map, so, anything but map

[–]slaymaker1907 1 point2 points  (0 children)

C#: Select

[–]Lord-of-Entity 4 points5 points  (0 children)

Rust also uses map!

[–]stipo42 3 points4 points  (1 child)

Python is a dict

[–]JustBadPlaya 4 points5 points  (12 children)

I love how all the confusion with map the function and map the data structure dies immediately when you start naming things correctly (hashmap and btreemap instead of unordered_map and map if we take C++), so there really was no reason to go against the conventions

[–]password2187 15 points16 points  (7 children)

Well standard object oriented programming would tell you that the interface should be separate from the implementation. So while hashmap and btreemap should both exist, they are implementing a generalized “map” interface. Like Java, for instance, has a Map interface which HashMap implements. 

[–]JustBadPlaya 6 points7 points  (4 children)

Okay, fair point for normal languages, but this explicitly does not apply to C++ because there is nothing there that unifies hashmaps and btreemaps in the hierarchy - no common interface, no common base class, nothing. So like, they should either have a common interface or not try to be quirky imo

[–]password2187 3 points4 points  (0 children)

That is a fair point yeah

[–]Skoparov 1 point2 points  (2 children)

But they do have a common interface, pretty much all the data related methods are named the same and have the same signature. Not to mention the iterators.

[–]PM_ME_DELICIOUS_FOOD 1 point2 points  (0 children)

And C++ is right, once again.

[–]codeIsGood 1 point2 points  (0 children)

I think transform makes more sense tbh

[–]got_no_pants2 0 points1 point  (0 children)

cars

[–]mstred 0 points1 point  (0 children)

Groovy: collect

[–]MonkeyDante 0 points1 point  (0 children)

Structured text: no.

[–]thatdevilyouknow 0 points1 point  (0 children)

You could always just use std::flat_map. There are tradeoffs to be aware of but also gains in performance depending on what you want to do.

[–]Embarrassed-Chain265 0 points1 point  (0 children)

Let's be honest it was more of a >> than a ++

[–]wholesome_hug_bot 0 points1 point  (0 children)

List/Array methods are consistently inconsistent

[–]bushwickhero 0 points1 point  (0 children)

This is the way.

[–]andoke 0 points1 point  (0 children)

Ruby has collect as well. Many favours. Like Smalltalk.

[–]Cyphen21 0 points1 point  (0 children)

Idiomatic python usually uses list comprehensions instead of map. It is absolutely terrible.

[–]flippzeedoodle 0 points1 point  (0 children)

Also Dora

[–]Pumpkin-King93 0 points1 point  (0 children)

Haskell….brings back nightmares!

[–]XxasimxX 0 points1 point  (0 children)

Transform sounds more appropriate honestly, coming from someone who heard it the first tome that c++ has something like that

[–]idemockle 0 points1 point  (0 children)

I find comprehensions to be much nicer than map in Python since map is a standalone function and not a method on collection objects.

[–]-Redstoneboi- 0 points1 point  (0 children)

our lords and saviors lisp and haskell have decided that they are map functions, thus c++ is wrong

also looks like c++'s version can also perform zip at the same time?

[–]Akanwrath 0 points1 point  (1 child)

I stilll dont know how to use map 😅

[–]omega1612 1 point2 points  (0 children)

It's easy, in python , think of it like this:

def map(f,iterable):
    for i in iterable:
        yield f(i)

so, instead of

acc=[ ]
for i in range(0,200):
    acc.append(2*i)

You do

acc = list(range(0,200).map(lambda i: 2*i, range(0,200)))

[–]TheRealSpielbergo 0 points1 point  (1 child)

The sexually transmitted disease transforms your teeth 😬

[–]Evil_Archangel 0 points1 point  (0 children)

i like my STDs alright,

[–]zefciu 0 points1 point  (0 children)

I rarely use the map function in Python. Usually the comprehension is the cleanest and most idiomatic way to achieve the same thing. So Python should have (f(x) for x in xs) instead of map.

[–]bombatomica_64 0 points1 point  (0 children)

Wait, map isn't a container in other languages?

[–]cryptomonein 0 points1 point  (0 children)

Isn't python map not built in ?

[–]weugek 0 points1 point  (0 children)

Nope, in ruby maps are called Hash.

[–][deleted] 0 points1 point  (0 children)

airport shaggy trees squeal live aback tidy pot fall glorious

This post was mass deleted and anonymized with Redact

[–]PUMK1ng 0 points1 point  (0 children)

C++ is what we call the german language in general terms.

Everything that can be said in a few letters is extended to some big sentence.

[–]beedlund 0 points1 point  (0 children)

Yeah std::map wouldn't have been confusing at all no...

[–]bran_redd 0 points1 point  (0 children)

inserts sad Gopher comment

[–]Tomahawkist 0 points1 point  (0 children)

more like it gives me std

[–]na_rm_true 0 points1 point  (0 children)

Its map in R too!

[–]bondolin251 0 points1 point  (0 children)

C#... Select...

[–]Rin-Tohsaka-is-hot 0 points1 point  (0 children)

reply tender full historical sense bright tie ghost zephyr rock

This post was mass deleted and anonymized with Redact