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
gonadic io
Feb 16, 2011

>>=

LordSaturn posted:

what does this notation mean. is this a lambda? assume I am OOP with C# and Python experience, because I am

yes it is a lambda

Adbot
ADBOT LOVES YOU

LordSaturn
Aug 12, 2007

sadly unfunny

gonadic io posted:

yes it is a lambda

so you have a class with a member that basically says "do stuff to my private members which I will pass to your lambda as arguments, return a new thing for me to be"?

and then... somebody... changes the order in which the "do stuff" arguments are evaluated? who changes the order? to what end?

does monad.next() actually change internal state or do the monadic return values mean you're operating on a "branch" from the base?

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
All detail about the monad is hidden within the monad, so whether it changes internal state or not is not really a coherent question - in the language where monads are really a "thing", Haskell, there isn't an internal state to change. Think of LINQ - it doesn't matter if .Select actually modifies some internal collection or just aggregates the operation as long as the collection at the end is what you expect it to be.

If you want to see a real instance of 'a member that basically says "do stuff to my private members which I will pass to your lambda as arguments, return a new thing for me to be"', just look at LINQ's .SelectMany, a good example of a bind function.

Mahatma Goonsay
Jun 6, 2007
Yum
monads are types that satisfy a bunch of weird rules that allow you to do cool things with said type.

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Plorkyeran posted:

why does it matter? i'm sometimes annoyed when things are written in java because ugh now i need to install a jvm but go's problems are mostly just things that effect programming in it and not using programs written in it

i'm not really excited to use them, i'm excited to contribute to them except for the go thing

HoboMan
Nov 4, 2010

the only thing i don't get is i was told a thing is a monad if and only if it implements flatmap

when i asked here earlier someone said that was sorta true, but then didn't elaborate

i don't get how plain map doesn't count

gonadic io
Feb 16, 2011

>>=

HoboMan posted:

the only thing i don't get is i was told a thing is a monad if and only if it implements flatmap

when i asked here earlier someone said that was sorta true, but then didn't elaborate

i don't get how plain map doesn't count

it's just by definition. a thing is called a monad if it implements flatmap (and singleton for lists), whereas just implementing map is called a functor.

the reason why it's flatmap and not just map, is (if you excuse the pseudo-haskell):

map: (A -> B) -> List<A> -> List<B>
flatMap: (A -> List<B>) -> List<A> -> List<B>

the function in flatMap can interact with the container (monad) and so choose how many elements it can return (none, or 1, or a million) but the function in map can only ever return one element.

think if they were futures instead of maps - flatmap's function is free to start it's own future to chain operations asynchronously but map's function can only return immediately and can't return a future else you'll end up with Future<Future<B>> which isn't what you want (and you a function of type Future<Future<B>> -> Future<B> which is the alternate definition of a monad)

Mahatma Goonsay
Jun 6, 2007
Yum
So they do different things based on the type that they are. So in haskell for lists, they work like a weird non deterministic map function but for other types they can do different things. The >>= bind function allows you do take a monadic value and pass it into another function that takes a normal value and returns another monadic value.

code:

[1,2,3] >>= \x -> [x,x+1,(x^2)]
[1,2,1,2,3,4,3,4,9]

VikingofRock
Aug 24, 2008




HoboMan posted:

the only thing i don't get is i was told a thing is a monad if and only if it implements flatmap

when i asked here earlier someone said that was sorta true, but then didn't elaborate

i don't get how plain map doesn't count

The function given to the monad has to return the same type of monad. So in the case of a list, the function being applied has to return a list. This function is applied to every element in the first list, giving a list of lists, and then these are concatenated (this is flatmap). If we remove the constraint that the applied function's return type has to be the same type of monad (so in this case if we let it return anything, not just a list), then we have something different called a functor. That's also useful, and lots of things are both (in fact every monad is also a functor, but let's not get into that). Lists are an example of something which is both: they are monads (via flatmap) and functors (via map).

VikingofRock
Aug 24, 2008




Mahatma Goonsay posted:

So they do different things based on the type that they are. So in haskell for lists, they work like a weird non deterministic map function

I've never really liked this description of how the list monad works. It's perfectly deterministic (it's just flatmap). Flatmap can be used to model nondeterminism, but it doesn't need to be. (Not bashing you in this post, I just think that introducing the list monad as being linked to nondeterminism leads to misconceptions)

Mahatma Goonsay
Jun 6, 2007
Yum
yeah, i think that is how they talk about them in lyah which i was reading through last week, hah.

HoboMan
Nov 4, 2010

VikingofRock posted:

The function given to the monad has to return the same type of monad. So in the case of a list, the function being applied has to return a list. This function is applied to every element in the first list, giving a list of lists, and then these are concatenated (this is flatmap). If we remove the constraint that the applied function's return type has to be the same type of monad (so in this case if we let it return anything, not just a list), then we have something different called a functor. That's also useful, and lots of things are both (in fact every monad is also a functor, but let's not get into that). Lists are an example of something which is both: they are monads (via flatmap) and functors (via map).

thank you for explaining without getting haskell involved

Progressive JPEG
Feb 19, 2003

monads and strife

LordSaturn
Aug 12, 2007

sadly unfunny

back

Asymmetrikon posted:

Think of LINQ - it doesn't matter if .Select actually modifies some internal collection or just aggregates the operation as long as the collection at the end is what you expect it to be.

I think it absolutely matters whether calling .Select repeatedly on the same list can change the list, because it might change the results of the later calls. I'll look at .SelectMany when I get home, because I've never used/seen it before. (I have grievous mistrust of LINQ due to production code I've seen, but LINQ is probably cool and good in C# and I should get over it)

also I'm still confounded by this

LordSaturn posted:

and then... somebody... changes the order in which the "do stuff" arguments are evaluated? who changes the order? to what end?

Luigi Thirty
Apr 30, 2006

Emergency confection port.

while we're on the subject of 3D graphics here's an old SIGGRAPH paper from Owen Rubin about vector graphics games from the 1980s

https://www.siggraph.org/publications/newsletter/v32n2/contributions/rubin.html

quote:

For several games, Atari used a thing called a "math box" to do some 3D calculations. This was originally created by hardware engineer Jed Margolin for a game I was working on with Ed Logg called Malibu Grand Prix. Malibu was a first-person driving simulator with a point of view from inside the car. Unlike other driving games of the time, you could drive anywhere and were not limited to staying on a fixed track. Unfortunately, because of the limited capacity of the hardware and the limited amount of displayed information, it was hard to tell where you were actually driving much of the time. This game was quickly junked.

The math box was later modified for use in Battlezone and Red Baron (an airplane combat game). But because the cost of this box was quite high, it wasn't used in many other games. Ed Rotberg, the programmer for Battlezone, recalls using the math box:

"The math box consisted of a set of 2901 bit-slice processors. In Battlezone it was used strictly to do the "3D" calculations for the display. In point of fact, we only did 2D rotations and hacked the very little motion that was done in the Y axis. The math box was passed a 2x2 rotation matrix and -- I believe -- a list of points to rotate. If I remember correctly translation was handled in the 6502, although this may have been done in the math box as well. It's been a long time."

Mike Albaugh,1 one of Atari's first game programmers, and still with Atari Games today, wrote the microcode for the math box. He explains its functions as follows:

"The math box appeared to the game programmer as a memory-mapped I/O device. 'Storing' to one of 32 locations would jam a micro-code address into the 'PC,' and result in some routine being executed.

I am surprised, looking at it again after many years, that the internal coordinate system seems to have had X into the screen, with Y (H) and Z (V) on the surface of the screen. I can only assume that this was a holdover from Jed Margolin's original 'Malibu Mathbox,' for which this one was supposed to be a 'stop-gap replacement' :-)

Anyway...the routines provided were pre-sub (X' = (X-E)*A+(Y-F)*B) and post-add (X' = X*A+Y*B+E) multiplies, with the latter 'falling through' (after computing X' and Y") to the Y'/X' 'perspective divide' (remember the coordinate system) Whew! Believe me, it was harder for me to extract that from the code and comments than it was for you to read it. The 'commands' were:

"Set Y-High, start Multiply"

"Set Y-High, start Multiply, post-add"

"Start Y' multiply" (after reading X' from pre-sub multiply)

"Divide Y'/X'"

"Divide Z/X'"

"Clip"

"Distance" (approximate sqrt((X1-X2)^2+(Y1-Y2)^2)

This was done with 256x24 bits of microcode and four four-bit 2901 bit-slice datapath elements."

raminasi
Jan 25, 2005

a last drink with no ice

LordSaturn posted:

I think it absolutely matters whether calling .Select repeatedly on the same list can change the list, because it might change the results of the later calls. I'll look at .SelectMany when I get home, because I've never used/seen it before. (I have grievous mistrust of LINQ due to production code I've seen, but LINQ is probably cool and good in C# and I should get over it)

linq is definitely cool and good

comedyblissoption
Mar 15, 2006
Probation
Can't post for 5 hours!

MALE SHOEGAZE posted:

i've been one of go's major detractors ITT but i've been using it seriously / heavily for the last 2 months and I've really enjoyed it. idk what to say.

it may just be that it's the first time i've gotten to use a typed language professionally and after mostly being stuck in the ruby pit it's very nice
it's a downgrade from any other statically typed language not willfully stuck in the 70s

but yah i think it's hard to argue that it's not better than most dynamically typed langs, but that's mostly b/c dynamic typing is that horrendous of an idea

comedyblissoption
Mar 15, 2006
Probation
Can't post for 5 hours!
the most generous description of golang is probably it's a better python

jony neuemonic
Nov 13, 2009

comedyblissoption posted:

it's a downgrade from any other statically typed language not willfully stuck in the 70s

yeah, wait'll you try one of the ml-family languages.

:catdrugs:

Space Whale
Nov 6, 2014

Progressive JPEG posted:

monads and strife

I/O in the lightning! In the lightning!

WHEEEEEEEEEEE

Luigi Thirty
Apr 30, 2006

Emergency confection port.

There seems to be a porblem



perspective projection introduces rounding errors into the triangles' screen coordinates that i haven't worked out yet

cinci zoo sniper
Mar 15, 2013




what's the deal with people throwing up 219 plugins on top of vim to make an ide "replacement" out of it

Brain Candy
May 18, 2006

kalstrams posted:

what's the deal with people throwing up 219 plugins on top of vim to make an ide "replacement" out of it

they haven't heard of spacemacs :shrug:

HoboMan
Nov 4, 2010

notepad++ suits my needs

FamDav
Mar 29, 2008

LordSaturn posted:

also I'm still confounded by this

so if a monad looks like

code:
monad.next({|x| gently caress with and return an x})
then when you write a monad it has total control over what happens with the function being passed in. so for a list (let's assume you can just define a new method on list) it might look like in some pseudo-c#-java

code:
List<T> next(Function from T to List<Y> f) {
  List<Y> result;
  for (T t : this) {
     returnList.appendAll(f(t));
  }
  return result;
}
or for an Optional<T> (a fancy wrapper around null which you can ask isPresent and get)

code:
Optional<T> next(Function T to Optional<Y> f) {
  if (this.isPresent()) {
    return Optional.of(f(this.get()));
  }
  return Optional.empty();
}
So the monad itself owns when things in the next blocks are evaluated.

VikingofRock
Aug 24, 2008




kalstrams posted:

what's the deal with people throwing up 219 plugins on top of vim to make an ide "replacement" out of it

I spend a lot of time in various headless environments. Vim and git are usually already installed, and my .vimrc is on github, so a quick git pull is all I really need to get set up and coding on a new machine (it's really nice to have the IDE features and write-time static analysis when writing bash and python janitoring scripts). The other reasons are (1) vim is language independent and I often code in a few different languages, and (2) I like to stay on command line and avoid using the mouse when possible, and vim lets me accomplish that.

VikingofRock fucked around with this message at 05:42 on Jul 2, 2016

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?

kalstrams posted:

what's the deal with people throwing up 219 plugins on top of vim to make an ide "replacement" out of it

they read about how using vi was "more efficient" in some post on Hacker News and are cargo-culting that because they're hipsters

but they're trying to turn it into an IDE so they can get actual work done in a text editor designed as a hack atop a line-oriented editor for teletypes before modeless editing was a thing, because such an editor isn't actually all that efficient for just basic editing

abraham linksys
Sep 6, 2010

:darksouls:
i stopped using vim when i started using typescript and needed ide features, turns out atom's vim mode is the first vim emulation in any editor that's actually any good so it works out

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

abraham linksys posted:

i stopped using vim when i started using typescript and needed ide features, turns out atom's vim mode is the first vim emulation in any editor that's actually any good so it works out

evil mode man, it's miles ahead of atom

abraham linksys
Sep 6, 2010

:darksouls:
the whole reason I'm not just using vim is that I want an editor with a real GUI for IDE features and emacs ain't that

cinci zoo sniper
Mar 15, 2013




makes some sense for people already familiar with it, i guess, and tunneling elsewhere etc

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

abraham linksys posted:

the whole reason I'm not just using vim is that I want an editor with a real GUI for IDE features and emacs ain't that

emacs is an ide with a gui

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

MALE SHOEGAZE posted:

emacs is an ide with a gui

that's nice, dear

Valeyard
Mar 30, 2012


Grimey Drawer
Pycharm is ownage

Valeyard
Mar 30, 2012


Grimey Drawer
It's version control integration is terrible though

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Wheany posted:

that's nice, dear

he's already a vim user, if he was happy with vim and needs and ide, evil emacs is such a clear choice.

im not telling someone who prefers guis to switch to emacs

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
what's the benefit of emacs/evil over something like vim + YouCompleteMe? i've never used emacs

cinci zoo sniper
Mar 15, 2013




Valeyard posted:

It's version control integration is terrible though
yeah i love pycharm for python, but youll have to pelt me before i use the inbuilt vcs functionality versus something like sourcetree

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Asymmetrikon posted:

what's the benefit of emacs/evil over something like vim + YouCompleteMe? i've never used emacs

emacs is an ide.

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006
emacs is not an ide. emacs is a text editor

  • Locked thread