Algorithms + Data Structures = Programs - Episode 42: Inverse Algorithms and More!
Episode Date: September 10, 2021In this episode, Bryce and Conor talk about inverse scan and inverse iota, working remotely, respond to some tweets and more!Date Recorded: 2021-09-01Date Released: 2021-09-10Tweet about I for INTELBl...oombergXKCD CompilingADSP Episode 39: How Steve Jobs Saved Sean ParentTweet about car crash is “a rotate”Tweet about “A Discussion with Sean ParentTwo’s Complement PodcastArrayCast PodcastInverse Scan ExampleC++ std::partial_sumC++ std::adjacent_differenceInverse Iota ExampleC++ boost::hana::flipJ :. (obverse)Intro Song InfoMiss You by Sarah Jansen https://soundcloud.com/sarahjansenmusicCreative Commons — Attribution 3.0 Unported — CC BY 3.0Free Download / Stream: http://bit.ly/l-miss-youMusic promoted by Audio Library https://youtu.be/iYYxnasvfx8
Transcript
Discussion (0)
J, APL, the array languages, they're coming to C++.
This is the first step.
Welcome to ADSP, the podcast, episode 42,
recorded on September 1st, 2021.
My name is Connor, and today with my co-host, Bryce, we start off by responding to some tweets, talk about
working remotely, and then talk about inverse scans and inverse iota.
But so this means that this is episode 42, pretty special episode.
We should start off by reading some tweets because we've gotten a lot of tweets.
Why is it a pretty special episode?
Episode 42.
Come on, man.
Okay.
You don't know the significance.
You know the significance.
I get the reference.
I was just not sure if that's the direction you were going.
But okay.
Wow.
Come on, man.
You got to trade some of that decorator knowledge for like nerd
swag uh um you also gotta sit a little closer to your mic you sound like you're in like the
notre dame i i think that's just my my ceilings are very like i don't know that's gonna get better
all right so feedback from feedback from listeners we're reading feedback because
there's primarily one one thing i want to read, but we'll read out a bunch of things.
So a few episodes ago, we were talking about creating a new acronym based on C++ companies because NVIDIA is not in the FANG acronym.
So we were talking about...
That's not the only reason that we dislike FANG.
We were also like... We don't dislike Fang.
I dislike Fang.
I don't like that.
I feel like it wasn't about NVIDIA.
I was like, why is Netflix on there but Microsoft isn't?
But yeah, no offense to people who work at Netflix,
but I don't understand why you're classified in the same league as those other companies.
And I guess part of it is a number of those companies in Fang are platform companies.
Google and Apple both have this huge developer ecosystem around them.
That's not the case for Netflix.
It is the case for Microsoft.
So I just sort of find it... And I think also in many ways it is the case for Facebook too.
There's an ecosystem around Facebook. But Netflix is a different type of tech company
and a different type of tech giant. And so I think that it's a little bit out of place for
it to be in that group. It's like no offense to Netflix.
It's a great company.
Obviously, it produces a great product.
I think it's a really cool place to work.
But I think it's a different type of tech company than the rest.
But anyways.
I agree.
I would venture a guess.
If you had to name like the top five, I don't want to say paying, like salary paying. And then like Netflix is known for paying ridiculously well.
Like their whole thing is that you don't even really need to, you don't even really need to like salary negotiate.
They do a ton of like industry research on what top dollar is for their position.
And then they pay that to you almost entirely in base compensation like they
don't really have like a variable component because their philosophy is if you no longer
like working there they don't want you sticking around because you've got like rsu's vesting
which is like the complete opposite of like amazon which is their vesting schedule is like 5 15 40 40
which means 80 of their rs user paid out two
years in the last two years of like a four-year stint but but like like out of that list of like
well-known companies that like pay well that you just listed i think it's it's really hard to make
that list and not include microsoft like like look i understand you don't include nvidia in
that list because
we're not in the same class as those companies, but I think it's really hard to talk about Apple,
Google, Facebook, and not also talk about Microsoft. Yeah, that's true. I guess that is,
so it's a bit of, you can make the argument for Netflix and then backronym it, right? Because you
had A-A-F-G and and if you add m i think we already talked
about this what do you get you get you get gampha or something like that yeah whereas if you if you
if you what did this listener have to say oh so so we had said let's create our own acronym uh we
were talking to sean so it was adobe netflix you wanted to include microsoft because they were left
out of the the fang yeah and so we and said, well, what word could we go for?
And I mentioned Maine,
if we could find an,
I,
a company that started with I.
And so we had a,
we had a,
if I,
I mispronounce any of these names,
I,
I profusely apologize,
but Mahir,
uh,
Vadya said,
uh,
which company starts with I inner voice,
Intel,
inner voice,
Intel voice. Okay. We will let the listeners tell if any company starts with I? Inner voice, Intel. Inner voice, Intel. Voice, okay, we will let the listeners tell if any company starts with I.
Funny that neither of us thought of Intel considering.
Well, I thought of Intel, but I thought we said Intel.
We did not.
We couldn't come up with a company that started with I.
So my question is, do I have to cut this whole part out of the episode?
Because we're not really our rivals we're in a class of our own
okay no no i like it i like it main microsoft adobe intel netflix. Netflix and video. And video. I would claim
jet lag, but that's probably
not going to hold up.
Eric Keane, right? He works at Intel.
He's a class act.
He's really great. And Jeff Hammond,
he just came from Intel, and he's a super nice
guy. Of the people
that I know that have come from
or are at intel they're they're lovely people so yeah yeah yeah no and i mean intel's intel's a
cool like and you know one of the interesting things about that acronym is it doesn't name
all of the big c++ orgs but it gets most of them.
Intel's big and invested in C++.
So is Adobe.
It's a classic C++ shop, and so does NVIDIA.
Outside of the FANG companies that also are, what would you name?
Bloomberg, obviously.
Yeah, yeah, we'd have to work Bloomberg in.
Do we have to work Bloomberg in? All all right so do we need a new yeah because bloomberg bloomberg is one of the um bloomberg
is one of the largest investors in the c++ community yeah um it's one thing that you know
bloomberg doesn't really like if you look at if you look at um financial tech companies of which Bloomberg is, it would be wrong to classify Bloomberg as like an HFT company because that's not what they do. it's almost like market services, you know, data, information, you know, the stream of information
about various markets. So like in some ways, they're sort of like a news, you know, or,
but they're definitely like, you know, I think they fall under the guise of financial tech.
But there are a few others that invest in the C++ community like Citadel, but by far the most present one is Bloomberg.
I learned something interesting about Bloomberg because I was having dinner with one of my colleagues, Alistair, who works at Bloomberg.
And he told me that at Bloomberg, they've got – so they're based in Manhattan. And until a few years ago, they didn't like remote work
because they felt that you lost something,
you lost some element of collaboration by not having everybody local.
But they did this other thing, which is very interesting,
which is they've got three or four different sites within the city.
And every few years, your team and your org moves where your office space is,
maybe within the same building, but also maybe you move from one of the offices in Manhattan to a different office. And this consistently happens every few years that everybody gets moved.
And it's like important to them that everybody gets moved so that you don't get used to being in one place.
And the idea is that like you move around, you move around where all the different teams are to so that every few years, hey, you're sitting next to a new group of people and you get exposed to a different part of the company.
And then that way, like there's more chances for synergy.
And that it's something that becomes a regular part of the culture.
So so once you like if you if your desk is going to be moved every year, you know, one, the company gets used to doing these moves into you, the employee get used to it.
So it's not a big hassle. So I thought that was interesting yeah that is interesting i've never
heard of anything like that um yeah other than sort of like open office or open concept where
you don't really have a desk and you just float around yeah like i think that's quite different
i think valve does that yeah i was at an insurance company before i was a dev that ended up doing that
really but like when you think of like innovative um uh office seating practices you don't think of
insurance companies yeah i mean the company that i'm i was referring to was manulife and they um
they tried to they're trying to be,
they developed,
this was after I left,
but I heard that they set up a team called Loft,
which stood for the laboratory
of forward thinking
where they were trying to generate
these really unique,
you know, insurance ideas and policies.
So like, I think,
I'm not sure if it was out of Manulife
or they copied another company,
but I definitely know that there's a policy in Canada through Manulife that you can
get where you wear a Fitbit, and it keeps track. It's like an insurance company issued Fitbit.
And it keeps track of like how active you are. And you can get like a reduced premium by doing
exercise. And also, there's similar things for car insurance in Canada where you can get like little brake measurements to see like how much you're braking and, you know, sort of like how safe you're driving and whatnot.
And that affects your insurance premiums for vehicle insurance.
So there's some neat ideas.
This is a thing that's not as common these days.
But I actually I was reminded of this because I was watching an episode of the TV show Mad Men.
I've been watching a bunch of New York-based TV shows to get myself in the New York mood.
And also, if we're being honest, Mad Men has a lot, a lot of the furniture in Mad Men is mid-century modern style, which is the style that I prefer.
So I've been watching TV shows looking for decorator ideas.
But there's one episode where one of the main characters is going to get his physical,
and the doctor says, oh, like, you know, you're only in here because your insurance company is requiring it.
And this, like, used to be a thing where, thing where for your life insurance or your health insurance,
your insurance, and maybe it still
is, but maybe
it's just that people of our age
don't have that requirement.
But it might have used to be back in the day
that your insurance company would require you to go get a physical
every few years and then
send them the results, presumably.
I think today
people would think of that as an invasion of their privacy.
But I mean, maybe it's still a thing.
Who knows?
I think definitely it is for certain policies.
You have to be, quote unquote, underwritten.
Yeah.
Well, let me ask you this.
So you, when did you move back to Canada?
2019.
Pre-pandemic, of course.
Yeah, just a few months before the pandemic
do you think
and you were on a team that was a remote
that was a remote first team
by which I mean it was a team that was remote
even before the pandemic
the Rapids team at NVIDIA
you think you'd ever want to go back to working in an office
so the answer
to that question is if I have to choose 100% remote or 100% in the office,
I will always choose remote. The flexibility that you get and the time that you save from like not
having to commute, I think it outweighs the benefits of being in the office. I definitely
miss being around people, like especially COVID times.
I essentially live by myself. And I'm just isolated, except for when I socialize,
which isn't often because it's still sort of pandemic-y. And so yeah, like if I had it my way,
like there's an NVIDIA office, and I would probably go into the office for like two half days of a
week when I had like meetings, and I just take my laptop with me.
I wouldn't have a desk and I just sort of there's a space in the sort of like kitchen area where you can you can grab a place by a window.
And so you get to see people, you get to whatever chat a bit because I definitely miss that like water cooler aspect.
Like it's sort of hard to replicate that, especially when I've only met like four or five of the people that I work with in person. Yeah. But yeah, the convenience of like
being able to make a sandwich or, you know, go for a quick run in the middle of the day,
like when you're at work, the overhead of going to the gym or going for a run where you have to,
then shower and bring extra clothes and blah, blah, blah, and all this stuff. It's just a the overhead of going to the gym or going for a run where you have to, you know,
then shower and bring extra clothes and blah,
blah,
blah,
and all this stuff.
It's just a headache.
Yeah.
See,
it's interesting that you say that,
that you would go in for meetings because pre pandemic,
the days that I had all meetings might would the days that I like wanted to
stay at home because at the NVIDIA headquarters is
like an open office plan I can't have my meetings I can't take my meetings from from my desk well
there's a tolerance to how many meetings I could take from my desk before I would get you know
glares from my co-workers and we need to go get a you know a meeting room so those are the days that i would almost prefer to be at at at at home and like i i used to think because i was a big believer in like
you know that it was important to separate your work space from your living space for like work
life balance because like i i have a tendency towards being a workaholic, so I thought I used to not have a desk at home.
I used to try to never have a workspace at home so that I would have to go into the office when I wanted to work.
I did that when I was at Lawrence Berkeley Lab.
Also, when I was at Lawrence Berkeley Lab, I lived in this miserable little apartment that had like no AC and no ventilation.
So you didn't want to be in there during the day anyways.
But I...
And same thing when I was in Santa Clara, when I was at NVIDIA headquarters, I lived in a smaller apartment that didn't have space for a home office or a desk
that was really near headquarters with the thinking being, okay, if I want to work,
I'll drive five minutes into the office and then the home space is the home space.
And then at the start of the pandemic, I was like, well, I'll have to find them.
I'll have to figure out how I can fit a small desk into this tiny apartment. But I don't think I would
go back because no matter how short your commute is, at least for me, and I'm somebody who's,
you know, had ADD my whole life, the fact that I had to get up, put on clothes, you know, pack a bag of all the stuff I would need for the day, you know, eat a meal, get in a car and drive any amount of distance.
Like those series of actions were a barrier for me to start working.
And it was also a barrier for me to stop working. And that was
actually the more problematic part, that if I was at the office, and I was sort of like at the end
of my, you know, I'd run out of energy, but I like wasn't finished with my task. I couldn't decide
to just go, you know what, I'm going to have dinner now,
maybe I'll come back to this, you know, for 30 minutes after dinner. Or you know what, I'm just
going to go take a lunch or I'm going to go watch, you know, something on Netflix for an hour. Now,
I could do that middle thing of like, I could go like, you know, just sit at my desk and watch a video on YouTube at the office. But making that decision to return to the
living space was a thing that I would do once during the day. So it was like a big decision.
It was like once I decided I'm going to go home and be at home for some period of time,
then I have stopped working for the rest of the day.
And for me, like the greatest thing about being working at home is that
I can choose when I make those transitions. And it's not a commitment. So that makes it easier
for me to start working and easier for me to stop working.
And I think that that's actually led to me to have a better work-life balance than I previously had.
You know, if I reach the end of my day or like a period where I feel like I need to stop,
you know, I'll just do it. Or if I just like, if it's the middle of the day and I'm not feeling
like, you know, I'm just not feeling energy right now, maybe I'll just stop and I just like, if I'm, it's the middle of the day and I'm not feeling like, you know, I'm just not feeling energy right now.
Maybe I'll just stop and I'll go, you know, start cooking dinner or something.
Or, you know, go do some chores, some errands around the house.
And then I can go return to work later.
And it just, it just feels, it just like the ability to switch between those two things.
It's just a much better fit for me.
And I never would have guessed it for the pandemic. just like the ability to switch between those two things it's just a much better fit for me and i
never would have guessed it for the pandemic yeah i would have to say that i don't think i ever
it's it would be very rare if i ever sort of start my day and end my day within like a nine
hour um like fixed window especially due to the fact that my compile time is like 40 plus minutes
i'm i'm constantly like in the evenings,
even when I'm quote unquote, not working, like just still iterating on something that I know
if it's gonna take, you know, half an hour plus to compile, I'll be doing my own stuff. And I can
still, I can still like make quote unquote, like three to four hours of progress, where I'm really
only working for like less than an hour,
but that's going to take like, you know, half a day of compile time stuff.
I've gotten to a point where the stuff that I'm doing,
most of it is like strategy and planning.
And so if I do have a task that involves me like compiling or like for me,
it's maybe less the compile time
it's more like building like getting ci results back i'm lucky in that now i'm at a place that
i have a small enough portion of those tasks that i can always overlap them with something else
but uh but my one of my ex-girlfriends got me a signed copy of the xkcd comic where it's showing two programmers
fighting with wooden swords and um uh there's like their boss saying hey get back to work and
one of them's like code's compiling and it says under it the number one legitimate excuse for
programmers slacking off um yeah but yeah like like i I don't ever really work nine to five days, but, um, I have, I, I have days that are meeting days and I have days that are work days.
And I try to like, I try to not have meetings on days where like, I want to get work done.
Like I try to have all my meetings on Mondays and Wednesdays, but, um, it ends up where
now I do have some on Tuesdays and Thursdays because I have some committee meetings on Tuesdays,
um, and some other work meetings on Thursdays. Um, uh, but, uh, you know, like I might every
now and then I have that rare, you know, Tuesday or Thursday where I have nothing to do
and I can just say, Hey, from nine to five, I'm just going to work on this thing. And I usually
like take like one break in the middle of the day. But, um, like for me, at least like when I,
when I, when I have that rare, like chunk of like free time, like once I get started working on the
thing, like I can just go and work on it for like, you know, a good chunk of a like chunk of like free time like once i get started working on the thing like i can just go and work on it for like you know a good chunk of a good chunk of eight hours um it's
just like the getting started that's uh that's challenging and finding that time yeah there's
a huge overhead uh contact switch contact switching yeah yep yeah all right so back to
we went on a couple of huge tangents there um but we got we got one tweet
read at least yes all right let's let's go back to another user um there was a couple tweets along
the same line so sean post his uh car crash story um hopefully hopefully uh everyone has listened
to that episode that's listening to this episode
now if not find it in the show notes and sorry for the spoiler a couple of them said that uh
feel like sean parent missed the this is from gregory thane uh feel like sean parent missed
the punchline of his story drove apple's porsche too fast around a corner spun out
smashed the rear end uh into a pole. That's a rotate.
Which I thought was pretty funny.
And yeah, John Mullins said the same thing.
That's a rotate gone wrong.
Oh, audience, I love you all.
And then there's a couple different folks that have replied or retweeted saying that that's adp adsp has become one of their favorite podcasts so pedgman was
one of those individuals so thanks and also uh we're getting to the top um well and and you're
missing the one you know people are pointing out the new name for the podcast.
Yeah, yeah.
So that's the one we're getting to.
So Sam McDonald on August 27th.
And I retweeted this saying this is now officially the unofficial title of this podcast.
It's probably the best backron name I've ever come across.
And Sam tweeted,
ah,
always glad to see a new episode of ADSP,
AKA a discussion with Sean parent,
which is amazing.
Cause,
uh,
definitely we've had,
uh,
Sean on,
I think we've interviewed him three times,
but that's been split into like eight or nine episodes.
Yeah.
At least nine episodes. Yeah. And, um, and yeah yeah matt gobbult also tweeted out the other day that uh he's been
catching up on the podcast and really enjoying it um and learning about things he didn't think
he'd learn about like apl and matt for those of you that don't know also has his own podcast called
two's compliment um which is definitely worth a listen.
Oh snap.
And I didn't even see this one.
Um,
another backer name.
Actually,
that's a scan podcast.
That's not too bad.
That's,
uh,
shared.
That's from share the parens with your friends, which is an amusing,
um,
an amusing, uh, uh handle anyways yeah we were supposed to talk about um
we were supposed to talk about we were supposed to talk about something yeah yeah because i didn't
get the memo i was so we're gonna have to save it till i'm not even sure because i it would have
been nice if episode 42 was talking about this. But so while you were, you know, moving and packing and we weren't recording during August on my other podcast, Arraycast, I learned one day that APL and Jay have inverse scans.
So, OK. Yeah. So I think you mentioned this to me somewhere and I expressed some confusion.
I think you just saw the tweet and then you were like – you commented on it and were like, what's an inverse scan?
And then you said, or is that an episode of ADSP?
And I said, yeah, we'll wait.
We'll wait to talk about it.
So explain this to me because I'm really – so like a scan is –
If you want, you tell me what you think an inverse scan is and I'll tell you.
Well, okay.
Let me just talk through this.
So to me, a scan is of the family of, you know, a reduction.
It's where a reduction produces like one final result.
A scan produces all these intermediate results.
Really?
You consider a scan a reduction?
That's interesting. Not a reduction. I consider it of the family of a reduction because, you know, it produces all these partial sums. I think there are
a lot of problems that you might solve with a
reduction where a modified version of that that you might solve with a reduction where a modified version
of that problem might be solved with a scan. Yeah, I think that they're very similar.
And I think that they have a lot of similar properties in terms of like how they propagate
information and in how they deal with things like commutativity and associativity? Yeah, I'm going to stick with that. I'm sticking with my claim here.
So then the idea of an inverse scan immediately makes me ask, what would an inverse reduction be?
And I have no idea. But I mean, I guess I would think that an inverse reduction would mean information propagates the other way.
A reduction produces one result from many.
So maybe an inverse reduction would send one result out to many.
But I don't know that that helps me at all guess what an inverse scan is well so here's a clue is that in apl and j i i believe inverse reductions are not
possible at all okay and in fact there are certain inverse scans that are not possible
only certain types of scans can be inverted so for actually i'll pause there until you unless
if you want another hint and then if you want i
can give you an example of a inverse scan that can be inverted or a scan that can be inverted
and a scan that cannot be inverted yeah give me yes yes you want you want those hints okay so a
plus scan can be inverted but a max scan cannot what properties does Max have that Plus does not have?
This is fun.
Listeners can play along.
Maybe this will be a longer episode.
We'll go way past the 30-minute mark.
What properties does Max have that Plus doesn't have?
You should ask yourself what properties does the result of a max scan have versus a plus scan?
Because both plus and max are both associative and commutative.
Right, right.
Property-wise, they're very similar.
Does the result of it have?
And here, I'll give you even another hint because this is i'm getting too
excited sitting here tech technically the equivalent of an inverse scan exists as an
algorithm in the c++ standard library is it like an adjacent is Is it adjacent difference? It is.
Yeah.
Okay.
I see where you're going with this.
I think.
Which is like the inverse of a scan is like an adjacent difference.
So it's just like the localized values.
All right.
Tell me.
Explain it to me. To stay in the C++-topia for a little bit, and this was first pointed out to me by Christabella when we were discussing whether or not adjacent difference was broken or not. Because I have for a long time maintained that adjacent difference
is broken because it returns you n elements and it copies the first element of the input range
to be the first element of the output range. Listeners of this podcast have probably heard
me say that like three or four times by now. Chris's take was that it's not broken because the desired behavior of adjacent
difference was to be able to round trip with partial sum to get back the original input
sequence. So if you partial sum on the values one, one, one, one, one, you'll get back one,
two, three, four, five as the partial sum. And if you then take adjacent difference,
you can round trip back to your initial input and so there's this right yeah i don't see i don't see how you would
round trip if you were doing maxes exactly yeah so when you do a max scan um you cannot do the
inverse of that because you have you've lost information whenever you have sort of local minimums in between
values.
Whereas a plus scan inherently encodes every single piece of information in
between like adjacent elements.
Yeah.
But there is,
there is somehow that is in some way a property of max versus plus.
I don't know how to,
and you know what i i i will argue that there's probably there are i i assume when you said plus you meant plus on like integers
as opposed to i don't know like plus on strings or some other uh well so if plus is defined as cat nation it would still work right if you had
the characters or the strings a b c d e f g as all individual characters and then you did a what
about what about on like floating point numbers because you're going to have information loss
there i mean floating point is like there's always an asterisk next to that because of NANDs and stuff like that.
But I mean, and precision and whatnot.
But arguably, you can get back, you know, minus some precision and minus the corner cases of floating point.
You can get back your results.
Here's another one.
What about like a Boolean operator?
That also would not work.
So if you wanted to do like something something like an
all of you know because you're going to lose information there too yeah if you well so all
of is a reduction but if you did the equivalent like logical and uh scan and you had the sequence
like zero one zero one zero one that'll return you zero one one one one one one to the end
and you're only going to be able to find you know the one one one one one one to the end and you're only
going to be able to find you know the first element that was a one and then you've lost all
information cs it has to basically your binary operation combined with the scan has to encode
each of the values in the adjacent values and if your binary operation does not do that
then it's not so so that property there must be a name for that property.
I wonder if there's a mathematical
or a name from CS
theory for that property.
I do not know if it exists.
And it's interesting because... Maybe one of
our listeners will. I'm not sure
it's so much a property of the binary operation
as it is the resulting
scan combined with the binary op.
Because if you go 1 plus 2, as it is like the resulting scan combined with the binary op? Because like a plus,
like if you go one plus two,
you get three,
but like just looking at the binary operation on its own,
you've lost all information there, right?
The same way if you have like one max two,
you get back two,
you've lost, was it two zero?
You only know, you've lost information,
but it's the combination of the scan
with the binary operation.
Well, it's some property about whether there exists
like this inverting operation
where you can take,
can you take two of the results
that are next to each other
and recover the original from it, right?
Like, is there some operation that exists that you can take two of the partial sums and get back the original values right yeah yeah
and i don't know what that so yeah i bet that there is i bet that there is some mathematical
term uh that describes this well we've got got, I don't know how many,
we get on average like a thousand listens an episode.
Somebody will help us.
If you're a math background, add us on Twitter.
And if you don't have Twitter, you can find us on GitHub,
on my GitHub repo, or just go to the website.
Yeah, and that'll take you to the GitHub repo,
and you can post us a note.
I'd be very curious to know.
So how different is an APL inverse scan from like a generalized adjacent difference?
A generalized adjacent difference?
So like on a plus scan, it's basically the exact same thing what i mean is like
adjacent difference is not like it i believe it has like um it has like minus hard coded in etc
well it's the default binary operation um yeah but yeah so like if you do an inverse plus scan
on one two three four five you will get the exact same result. If you did an adjacent difference on one,
two,
three,
four,
five.
Um,
and it's funny because we also have a name for it,
for the generalized adjacent difference.
Uh,
we're getting adjacent transform in ranges because that's a better name.
And that's the one with the N minus one behavior.
But so,
so,
so is an inverse scan adjacent transform in c++ no um i mean
an inverse scan is just the inverse of the the possible scan uh we right right but is the is
the way that you would express that in c++ adjacent adjacent transform i would express
it with adjacent difference because
it actually it actually that right but that you can't always but that's only if it's a plus scan
um it's only if the binary operation is quote unquote invertible for the lack of the word that
we don't have for it but right but well but no no it's it's only if the uh hang on if if uh
if the inversion operation is i don't know no there is an overload of adjacent difference
it takes a binary operation yeah yeah okay yeah oh sorry yeah that's that's what i was like i was
thinking yeah if you're doing multiple like a multiply scan, you can get the inverse by just overloading the...
We only added the overload of adjacent difference that...
No, it's been there. It's been there since C++.
Yeah. And the whole other extension of this topic is that you get this inverse scan by doing,
using the power operator in APL, which usually you use with a positive number. So if you want
to perform some function two, three, four, five times, you go power two, but you can also go power
negative one and that inverts it. And that works on a variety of different functions.
So there's also explain, Oh, okay.'s also explain oh okay you apply the power
you apply the power operator to the scan operator correct um and so then what happens what happens
if you do a power two to a scan operator uh i believe it's going to scan twice do a plus scan
twice so if you start with one one one one one you're going to get back 1, 2, 3, 4, 5.
And then if you do that again,
you're going to get back 1, 3, 6, 10, 15, 15.
Yeah, is that right?
Yeah, it's almost like a derivative.
In fact, let's really quickly.
It is kind of like a derivative.
Do you want me to share my screen?
Yeah, go for it.
Users, I am now looking at a screen with a bunch of symbols so if we do
quirky symbols if we do they look like egyptian hieroglyphs that's reduction so we got plus scan
once and then if we uh do power two okay the power symbol is a little asterisk with two dots above it.
It's called the diarisis. Diarisis? Yeah. Diarisis. Yeah. Because this is, it actually
really makes a lot of sense. The power by itself, if you do two power five, you're going to get 32
because it's exponential. the the diorosis
typically is used to denote an operator so it's basically like just a power
operator it's exactly what it is and so yeah if you instead of if I go iota 5
back to iota 5 wait why did you not use iota in the previous example because we were we were
starting with uh we were starting with five ones initially so we went from five ones to one two
three four five because of the plus scan to one three six ten fifteen because of the power two
but if we want to do an inverse scan we have to start with iota 5 and then do a plus scan power negative 1,
and this is going to give us back 5 1s.
So you want to see some...
Why couldn't we do that?
I'm confused.
Well, so if we did it with...
Let's see how well you understand it.
Say if we replace the iota 5,
so instead of doing an inverse plus scan on iota five which is one
two three four five we do it on five ones what are we going to get back do you know it's going
to be like one zero zero zero zero look at that bryce there we go an apl expert so so here's here's the real fun what if we do iota inverse on one two three what's this gonna give
us iota inverse um what is the inverse of an iota well wouldn't that be like a sequence of ones
so remember it gives us back it basically gives it's like uh what did Adam from ArrayCast and Dialogue, he explained it as sort of Jeopardy, you know?
It's what gives us the sequence 1, 2, 3 when passed to IOTA?
Well, IOTA, I don't think of it, IOTA is taking, I think of it, IOTA is generating the sequence 1, 2, 3.
But what do you have to pass to it in order to get it to generate that?
Oh, like three?
Exactly.
Oh, interesting.
So APL's got inverse scans.
It's got inverse iota.
Yeah.
But it's interesting.
It gives you a scalar result.
I guess that makes sense.
I mean, it seems like a pretty useless um algorithm to me
like what's what are you going to use an inverse iota for other than to check maybe that you have a
monotonically increasing sequence that starts at one what happens what happens if you gave it
if you gave one two four two um what do you think is going to happen?
Gives you an error?
Gives you two, maybe?
Gives you an error at the main arrow.
Because it's not a valid IOTA sequence.
So I could imagine cases where that would be useful.
Like,
if you wanted to check that people
weren't plugging
IOTA sequences into your unit tests because you wanted actual check that people weren't plug if you wanted to check that people weren't plugging
iota sequences into your unit tests because you wanted actual real data you know could be a useful
algorithm yep it's but yeah no it's not super useful it's pretty awesome though they we've got
so any basically any verb not all of them a lot of of them don't work, but if you can think of a reasonable inverse for a function that you have,
it typically is there, which is super awesome.
Should ranges have a, should we have a range adapter that inverses,
that inverts an algorithm?
Would that even make, no, that, I don't know if that would work,
but should we have some CPO that inverts another CPO?
Oh, this has actually come up.
We've talked about this before.
We've talked about a flip operation.
I don't know if we talked about it here, but I think either you and I have talked about it or Christabella and I.
It exists in Boost HANA, right?
Yeah, yeah, yeah.
I think either you and I or Christabella. No, I think it's been you and I who have talked HANA, right? Yeah, yeah, yeah. I think either you and I or Chris DiBella.
No, I think it's been you and I who have talked about it, right?
Because didn't you want Flip for some?
Oh, yeah, yeah.
I go on and on about Flip.
It's the C combinator, a.k.a. Cardinal, the Cardinal bird.
But if we're going to have Flip, then shouldn't we also have Invert?
I mean, Invert is not a combinator invert is just right a cool operator
that that takes a function the way i imagine it works in apl just based on those examples you
showed it's not something where it's a generic algorithm right like it's something where that
like iota no like it's not some generic thing that like takes iota and knows how to invert it like that's like
some special wiring of logic that says hey like here's how you invert an iota yeah so i i think
for the the verbs or functions like where inverse and scan those do have like a table look up where
it's like oh if it's if it's a scan, this is the behavior or whatever. However, that being said, I do know that if you build up a point-free or tacit expression
that consists purely of...
A what?
Like if you build up a tacit expression or point-free,
which means that it doesn't mention its arguments.
Like you used some words there and then you like glided over them in your explanation.
Yeah, continue.
But if you... So my understanding is that there's some sort of i don't know what the algorithm is like
recursive descent or something like that but like a composition of uh functions that all have
inverses can also be inverted um yeah yeah yeah yeah yeah that i i'm sure that there's some
generic form like but but there's probably cases where the generic form falls apart.
There's probably cases where there are invertible algorithms that you, the user, could write, but that you would have to somehow customize APL's inversion operation to explain,
like imagine that IOTA was not a part of the core of APL.
And you wanted to write your own IOTA.
You'd probably have to express to it in some way how that inversion would work.
So this is at the limits of my knowledge, but that is exactly what is possible in J.
So in J, I believe they have an operator called obverse.
Why it's called that, I'm not sure.
But obverse enables you to define the inverse of a user-defined function,
if my understanding is correct, which is pretty dope.
So maybe that's a thing that we should have in C++.
We should have... Ladies and gents, look at that.
J, APL, the array languages, they're coming to C++.
This is the first step.
You act as if I can just unilaterally decide what C++ does.
I mean, you are chair of LOOG, right?
Isn't that like half the reason of this podcast is so that I can slowly warp your mind until, I don't know about this proposal, it doesn becomes clear to me that the chair is more a servant of the
participants than one might imagine.
Well, that sounds like a good place to end it.
Well, or let me put it another way.
When your chair, your job is no longer to individually contribute.
Your job is to help make sure that everybody else's individual contributions get a fair hearing and move ahead in a timely fashion.
A moderator.
Yeah.
Yeah, a fancy moderator yeah and i some somebody just told me that it's
not actually required for me to move to new york to take over titus's role as library evolution
uh chair i assumed that there was some throne that i had to go and and take from him but uh
but not so much thanks for listening we hope you enjoyed and have a great day