purely-functional Questions

8

Solved

The terms do appear to be defined differently, but I've always thought of one implying the other; I can't think of any case when an expression is referentially transparent but not pure, or vice-ver...

5

I have an array which I map over. I need to compare the current element with the previous. I am detecting if the current element is the same as the previous element by comparing their ids and doing...
Helban asked 3/9, 2019 at 7:57

3

Solved

I am trying to learn functional programming and Scala, so I'm reading the "Functional Programming in Scala" by Chiusano and Bjarnason. I' m having trouble understanding what fold left and fold righ...
Approbation asked 27/11, 2016 at 10:3

3

Solved

Pure functional programming languages do not allow mutable data, but some computations are more naturally/intuitively expressed in an imperative way -- or an imperative version of an algorithm may ...
Maxfield asked 16/8, 2011 at 5:56

5

Solved

I have code like this. How can I write it in cleaner, more elegant way using functional programming in JavaScript? I want to get rid of nested ternary expressions. Any ideas? props => ({ iconC...
Crimea asked 18/9, 2017 at 5:28

1

I am trying to identify pure functions in PHP code. A pure function is one where both these statements about the function hold: The function always evaluates the same result value given the same...
Stotts asked 10/10, 2014 at 9:37

2

Solved

The following &greet function is pure, and can appropriately be marked with the is pure trait. sub greet(Str:D $name) { say "Hello, $name" } my $user = get-from-db('USER'); greet($use...
Garrettgarrick asked 12/5, 2021 at 15:34

3

Solved

GNU C and C++ offer the const and pure function attributes. From the gnu online docs (emphasis mine): In GNU C and C++, you can use function attributes to specify certain function properties that m...
Whitacre asked 31/3, 2020 at 14:23

1

Solved

I have the same question as this one, but in the context of JavaScript. From Wikipedia: [a pure function's] return value is the same for the same arguments It's further claimed there that a pure ...

0

I want to embrace functional programming, and ensure that my pure functions not change state. How do I ensure that a function that I intend to be pure only calls other functions which are themselve...
Hunch asked 29/11, 2020 at 9:34

3

Solved

I am trying to understand functional programming from first principles, yet I am stuck on the interface between the pure functional world and the impure real world that has state and side effects. ...

3

Solved

I am dealing with the concept of functional programming for a while now and find it quite interesting, fascinating and exciting. Especially the idea of pure functions is awesome, in various terms. ...
Shogunate asked 11/8, 2013 at 14:24

3

Solved

Working through Haskell textbook chapters on different monads, I repeatedly get lost when the authors jump from explaining the details of bind and the monad laws to actually using monads. Suddenly,...
Jamey asked 15/5, 2020 at 7:49

4

Solved

I have undergoing the functional programming course by martin odersky in scala on coursera. However, I am unable to understand the solutions to the 2nd Assignment Funsets.scala. type Set = Int ...
Tackle asked 22/12, 2017 at 15:21

4

Solved

Kotlin beginner here. How do I take a list and without mutating it, create a second (immutable) list with one updated element at a specific index? I'm thinking of two ways, both of which seem like...
Mirage asked 21/10, 2016 at 20:30

2

Solved

While going through the definition for pure functions, it's generally defined with two traits: 1) Should produce same output given the same input 2) Should not produce any side effects Does it a...

4

Since I liked programming in Scala, for my Google interview, I asked them to give me a Scala / functional programming style question. The Scala functional style question that I got was as follows: ...

5

Solved

I often find this pattern in Haskell code: options :: MVar OptionRecord options = unsafePerformIO $ newEmptyMVar ... doSomething :: Foo -> Bar doSomething = unsafePerformIO $ do opt <- re...

2

as a beginner in Scala - functional way, I'm little bit confused about whether should I put functions/methods for my case class inside such class (and then use things like method chaining, IDE hint...
Macmullin asked 25/6, 2016 at 7:4

1

Solved

Going by the requirements of pure method(a method which has no side effects on outside world), I have found most of the times static methods meeting this requirement. We can't access instance varia...
Just asked 23/1, 2018 at 11:3

1

Solved

I have a decorator @pure that registers a function as pure, for example: @pure def rectangle_area(a,b): return a*b @pure def triangle_area(a,b,c): return ((a+(b+c))(c-(a-b))(c+(a-b))(a+(b-c)))...
Xenophobe asked 9/8, 2017 at 13:44

2

Solved

I am C# dev that has just starting to learn F# and I have a few questions about unit testing. Let's say I want to the following code: let input () = Console.In.ReadLine() type MyType= {Name:strin...
Juieta asked 30/7, 2017 at 13:19

3

Solved

In a pure functional language, the only thing you can do with a value is apply a function to it. In other words, if you want to do anything interesting with a value of type a you need a function (...
Lanchow asked 24/7, 2017 at 18:50

2

Solved

I've been reading about functional programming and its concepts. It's clear to me that when working in big projects you always need to mix (at some adequate level) multiple paradigms such as OO and...
Harleigh asked 19/7, 2017 at 16:51

2

Solved

I am confused by the guarantees GCC makes about optimizing pure functions (from online docs): pure Many functions have no effects except the return value and their return value depends only o...
Rodriquez asked 19/7, 2017 at 12:12

© 2022 - 2025 — McMap. All rights reserved.