functional-programming

Multi-Core and Concurrency - Languages, Libraries and Development Techniques [closed]

◇◆丶佛笑我妖孽 提交于 2019-12-18 10:01:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 months ago . The CPU architecture landscape has changed, multiple cores is a trend that will change how we have to develop software. I've done multi-threaded development in C, C++ and Java, I've done multi-process development using various IPC mechanisms. Traditional approaches of using threads doesn't seem to make it easy

Why did you decide “against” using Erlang?

吃可爱长大的小学妹 提交于 2019-12-18 09:59:46
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Have you actually "tried" (means programmed in, not just read an article on it) Erlang and decided against it for a project? If so, why? Also, if you have opted to go back to your old language, or to use another functional language like F#, Haskell, Clojure, Scala, or something else then this counts too, and state why.

What are the problems with an ADT encoding that associates types with data constructors? (Such as Scala.)

不羁的心 提交于 2019-12-18 09:59:28
问题 In Scala, algebraic data types are encoded as sealed one-level type hierarchies. Example: -- Haskell data Positioning a = Append | AppendIf (a -> Bool) | Explicit ([a] -> [a]) // Scala sealed trait Positioning[A] case object Append extends Positioning[Nothing] case class AppendIf[A](condition: A => Boolean) extends Positioning[A] case class Explicit[A](f: Seq[A] => Seq[A]) extends Positioning[A] With case class es and case object s, Scala generates a bunch of things like equals , hashCode ,

Learning functional/Clojure programming - practical exercises? [closed]

陌路散爱 提交于 2019-12-18 09:56:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm learning functional programming with Clojure. What practical exercises can you recommend? Online repositories with solutions would be perfect. One idea I can think of is going through all the popular algorithms on sorting, trees, graphs etc. and implementing them in Clojure myself. While it could work, it

Learning functional/Clojure programming - practical exercises? [closed]

守給你的承諾、 提交于 2019-12-18 09:56:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm learning functional programming with Clojure. What practical exercises can you recommend? Online repositories with solutions would be perfect. One idea I can think of is going through all the popular algorithms on sorting, trees, graphs etc. and implementing them in Clojure myself. While it could work, it

What is “lifting” in Haskell?

我怕爱的太早我们不能终老 提交于 2019-12-18 09:55:07
问题 I don't understand what "lifting" is. Should I first understand monads before understanding what a "lift" is? (I'm completely ignorant about monads, too :) Or can someone explain it to me with simple words? 回答1: Lifting is more of a design pattern than a mathematical concept (although I expect someone around here will now refute me by showing how lifts are a category or something). Typically you have some data type with a parameter. Something like data Foo a = Foo { ...stuff here ...} Suppose

Why can I not pass a function call (rather than a function reference or an anonymous function) to setTimeout()?

*爱你&永不变心* 提交于 2019-12-18 09:42:34
问题 Please ignore the fact that this code achieves nothing and apologies for what's probably an inane question! I understand that I cannot pass a function call into setTimeout() as the first argument, but why can I not do that? let names = ['Andy', 'Ross', 'David']; function printer (name) { console.log(name); } names.forEach(name => setTimeout(printer(name), 1000); Result: Andy timers.js:327 throw new TypeError('"callback" argument must be a function'); ^ I can solve the problem by instead using

Simple non-optimal unionfind in OCaml

谁说我不能喝 提交于 2019-12-18 09:31:45
问题 I wrote a OCaml program for union find algorithm. This algorithm I wrote is not optimal and is the simplest version. I put my OCaml code here because I am not sure whether this code is good enough or not (despite of the algorithm itself) , although this code can run without errors. This is the first time I wrote a complete working thing after I started to learn OCaml, so please help me by reviewing it. Useful suggestions will help me improving my OCaml skills. Thanks type union_find = {id_ary

Difference between Monads and Functions

风格不统一 提交于 2019-12-18 09:17:36
问题 Ok, about Monad , I am aware that there are enough questions having been asked. I am not trying to bother anyone to ask what is monad again. Actually, I read What is a monad?, it is very helpful. And I feel I am very close to really understand it. I create this question here is just to describe some of my thoughts on Monad and Function, and hope someone could correct me or confirm it correct. Some answers in that post let me feel monad is a little bit like function . Monad takes a type,

Is there a way to determine the signature of a Lua function?

妖精的绣舞 提交于 2019-12-18 08:26:08
问题 Recently, Lee Baldwin showed how to write a generic, variable argument memoize function. I thought it would be better to return a simpler function where only one parameter is required. Here is my total bogus attempt: local function memoize(f) local cache = {} if select('#', ...) == 1 then return function (x) if cache[x] then return cache[x] else local y = f(x) cache[x] = y return y end end else return function (...) local al = varg_tostring(...) if cache[al] then return cache[al] else local y