window.location = window.location.pathname+'?networks='+$("input[type='checkbox']:checked").map(function () { return this.value; }).get().join(',');
dat map:
Code:window.location = window.location.pathname+'?networks='+$("input[type='checkbox']:checked").map(function () { return this.value; }).get().join(',');
Rage9, thanks, I've explored a lot of python functional stuff, and have a decent amount of experience with JS functional stuff, but I have no idea what a monad is, for example, a good guide to the terminology would be good.
So what is a monad? Well, it’s a design pattern. It says that whenever you have a class of functions that accept one type of thing and return another type of thing, there are two functions that can be applied across this class to make them composable:
There is a bind function that transforms any function so that accepts the same type as it returns, making it composable
There is a unit function that wraps a value in the type accepted by the composable functions.
The main principle is "no side effects". A function must return the same results for the same arguments. No side effects, immutable data, all state you work with contains in function arguments. No shared state and deterministic functions eliminate a whole load of bugs and problems. Your function transforms this state and returns if for further transform. In real life there are side effects: when you do IO (Haskell) or when you send a message to another green process (Erlang), but these effects are highly localized.
I don't recommend python or js even if they have some functional features as these languages have global variables and do not have pattern matching. Try to write a simple app with Haskell (more or less academic research language) or Erlang (braindead simple functional language with emphasis on concurrent applications, battle tested in such companies as Ericsson or WatsApp), you'll see the difference. You might try Scala if you like JVM, but imo this language is overcomplicated, it's like C++ of functional languages.
In OO languages methods change objects properties. These are the side effects I was talking about, not just global variables. When you debug a function in a functional language and print function input, you can be sure that this is the whole data your function works with, as you just cannot access other things that could be changed from outside.It seems like "no side effects" should be the norm for well written code in any language. Is it just that functional languages force it?
sum(N) when is_integer(N) andalso N >= 0 ->
sum(N, 0).
sum(0, Acc) ->
Acc;
sum(N, Acc) ->
sum(N-1, Acc + N).