What is difference between functional and imperative programming languages?

Most of the mainstream languages, including object-oriented programming (OOP) languages such as C#, Visual Basic, C++, and Java were designed to primarily support imperative (procedural) programming, whereas Haskell/gofer like languages are purely functional. Can anybody elaborate on what is the difference between these two ways of programming? I know it depends on user requirements to … Read more

Why hasn’t functional programming taken over yet?

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. I’ve read some texts about declarative/functional programming (languages), tried out Haskell as well as written one myself. From what I’ve seen, functional programming has several advantages over the classical … Read more

What is an appropriate type for smart contracts?

I’m wondering what is the best way to express smart contracts in typed languages such as Haskell or Idris (so you could, for example, compile it to run on the Ethereum network). My main concern is: what is the type that captures everything that a contract could do? Naive solution: EthIO A naive solution would … Read more

Is there a software-engineering methodology for functional programming? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago. Improve this question Software Engineering as it is taught today is entirely focused on object-oriented programming and the … Read more

difference between foldLeft and reduceLeft in Scala

I have learned the basic difference between foldLeft and reduceLeft foldLeft: initial value has to be passed reduceLeft: takes first element of the collection as initial value throws exception if collection is empty Is there any other difference ? Any specific reason to have two methods with similar functionality? 8 Answers 8

List of strings to one string

Lets say you have a: List<string> los = new List<string>(); In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these: String.Join(String.Empty, los.ToArray()); StringBuilder builder = new StringBuilder(); los.ForEach(s => builder.Append(s)); string disp = los.Aggregate<string>((a, b) => a + b); or Plain … Read more

How can I count occurrences with groupBy?

I want to collect the items in a stream into a map which groups equal objects together, and maps to the number of occurrences. List<String> list = Arrays.asList(“Hello”, “Hello”, “World”); Map<String, Long> wordToFrequency = // what goes here? So in this case, I would like the map to consist of these entries: Hello -> 2 … Read more

Best explanation for languages without null

Every so often when programmers are complaining about null errors/exceptions someone asks what we do without null. I have some basic idea of the coolness of option types, but I don’t have the knowledge or languages skill to best express it. What is a great explanation of the following written in a way approachable to … Read more