Data dodania Pytanie
2017-04-22 13:04 F# throws warning in shadowing record type »
I have 2 record types having the same signature: type T1 = { a : int } type T2 = { a : int } let badFunc record = { record with a = 0 } let goodFunc...
(1) odpowiedzi
2017-04-22 10:04 Exponentiation using list comprehension »
I'm trying to solve the following exercise (I'm learning Haskell): Define x^n using a list comprehension. And I'm struggling to find a solution....
(3) odpowiedzi
2017-04-22 10:04 Functional Programming and business domain model »
Functional programming discourages the mutable state, and qualifies data structures as everlasting values. Variable may be assigned a new value (a new...
(1) odpowiedzi
2017-04-21 17:04 Clojure, Attempting to call unbound fn »
I tried to create factorial function in Clojure using recursion (defn fac[x] (if (= x 1) 1 (* x (fac (- x 1))))) Now, when I try to call the functi...
(1) odpowiedzi
2017-04-21 09:04 How to avoid loops when iterating over adjacent elements of a vector »
In Rust, how do I avoid writing these loops? The code takes a vector and multiplies three adjacent elements to a product. Hence, the outer loop goes o...
(1) odpowiedzi
2017-04-21 02:04 ScalaTest: Marking a scenario test as an expected failure »
When working through testing with FeatureSpec and using scenario, I have part of my code that sends a "failure" case class (i.e. ApplesNotAllowed) and...
(3) odpowiedzi
2017-04-21 00:04 How to write this code in a idiomatic/functional way? »
I'm trying to write this piece of python code in a more modular/reusable fashion and I'm having trouble writing it Consider this: lst = get_list_of_...
(1) odpowiedzi
2017-04-20 16:04 Get case identifier of discriminated union in pattern matching »
How can I get the inferred type after -> in pattern matching? For example: type Type = | Complex1 | Complex2 | Number of int | Integer of...
(1) odpowiedzi
2017-04-20 06:04 JavaScript terminology: do I (call / invoke / execute) a function? »
Is there a difference to the mentioned verbs which are used in relation to functions ? Initially, I thought they mean the same thing and people use i...
(1) odpowiedzi
2017-04-20 04:04 Scala/functional/without libs - check if string permutation of other »
How could you check to see if one string is a permutation of another using scala/functional programming with out complex pre-built functions like sort...
(2) odpowiedzi
2017-04-19 22:04 Scheme - Iterating Over Two Lists »
Hi all I am new at learning Scheme and often have issues with making parallels between an imperative language and a functional language. For example ...
(2) odpowiedzi
2017-04-19 12:04 Array pattern matching »
Is it possible to iterate through an array using pattering matching just like we do with lists in F#? I tried something like this: type Alphabet = A ...
(1) odpowiedzi
2017-04-19 07:04 How is lazy interpreted in recursive context? »
Here's the code from FPIS object test2 { //a naive IO monad sealed trait IO[A] { self => def run: A def map[B](f: A => B): IO[B] =...
(3) odpowiedzi
2017-04-18 20:04 Two operations in accumulate »
I tried to convert the following loop into a accumulate() call but i despicably failed: total = 0 for h in heat_values: total += h total -= t...
(3) odpowiedzi
2017-04-18 18:04 What's the difference between `type private MyRecord = {...}` and `type MyRecord = private {...}` »
What's the difference between type private MyRecord = { id : int } And type MyRecord = private { id : int } From what I read: In the f...
(1) odpowiedzi
2017-04-18 15:04 Scheme: Implementing a Quick-Sort »
I'm trying to implement a quick sort using scheme, some dudes here already helped me fixing my split function and now I'm asking for you help with com...
(2) odpowiedzi
2017-04-17 16:04 Binary tree maze generation in Elixir »
I have an implementation of a binary tree maze generation in Ruby, in a purely OO way. I'm trying to rewrite this in Elixir as a learning exercise but...
(1) odpowiedzi
2017-04-17 16:04 Why are there Uppercase Named Patterns in F#? »
In The F# 4.0 Language Specification, it said that: 7.2 Named Patterns If long-ident is more than one-character long or begins with an upperc...
(1) odpowiedzi
2017-04-17 15:04 Recursive function keeps turning infinitely python »
I am trying to write some code to solve this math problem: there is 8 teams and all of them will play football game each other (so total of 7+6+...+1 ...
(1) odpowiedzi
2017-04-16 18:04 Proper way of applying two (or many) option values to a function in F# »
Recently I discovered a style of programming which is very useful (and pretty) in functional world called Railway oriented programming. For example wh...
(2) odpowiedzi
2017-04-16 16:04 Filter/Reject Array of strings against multiple values using underscore »
I'd like to _.filter or _.reject the cities array using the filters array using underscore. var cities = ['USA/Aberdeen', 'USA/Abilene', 'USA/Akron',...
(4) odpowiedzi
2017-04-16 14:04 Use bind to chain continuous functions »
Result type is a new feature in F# 4.1: type Result<'T,'TError> = | Ok of 'T | Error of 'TError bind : ('T -> Result<'U, 'TError>) -...
(1) odpowiedzi
2017-04-15 19:04 How to use const with while loop in javascript »
Is it possible to use const with while loop in JS. I wonder if we can do something like this without using recursive function: const node = current; ...
(2) odpowiedzi
2017-04-15 19:04 What does this error mean in Scheme: "and: bad syntax in: and"? »
I am getting the following error "and: bad syntax in: and": (define test (lambda(list1 a b c d) (cond (null? list1) (and (eqv? a b) (eqv? ...
(1) odpowiedzi
2017-04-15 10:04 Difference between Function.call, Function.prototype.call, Function.prototype.call.call and Function.prototype.call.call.call »
I have checked many similar questions on stackoverflow, such as call.call 1 , call.call 2, but I am a newcomer, and I cannot make comment anywhere. I ...
(2) odpowiedzi
2017-04-14 19:04 How to support structurally-typed in a nominal-typed language? »
In F#, Nominative or Structural?, the answer said that I can trick F# to work like a structurally-typed language via some exotic mechanisms. How can I...
(1) odpowiedzi
2017-04-14 16:04 Access to F# record base properties without using interface »
F# records cannot be inherited, but they can implement interfaces. For example, I want to create different controllers: type ControllerType = | B...
(2) odpowiedzi
2017-04-14 15:04 Pattern matching for return values »
I know I can use pattern matching for function parameters like this: fn :: (Integral a) => (a,a) -> (a, a) fn (x,y) = (y,x) But how can I mat...
(2) odpowiedzi
2017-04-13 17:04 Inner lambda reference Outer lambda variable »
There is a Outer lambda that contains inner lambda whis tries to reference var in Outer lambda, how does it possible? Im try to understand what this e...
(2) odpowiedzi
2017-04-13 16:04 Gen for a custom data type in Haskell »
I was trying to make a truth table for a list of strings. Say, I have a list ["a","b"] and as an output, I want [[("a",True),("b",True)], [("a",True...
(1) odpowiedzi
2017-04-13 14:04 Type parameter declaration in Scala »
I am newbie and learning Scala programming. I am struggling with following code. if I tried to replace "(Double, Double)" in "def combine" function wi...
(2) odpowiedzi
2017-04-12 22:04 Lisp - Logical operators »
I am new to Lisp so this might be so simple but I am curious to know about this in any case. I am familiar with logical operators like AND and OR but...
(2) odpowiedzi
2017-04-12 21:04 Java 8 stream min is not returning expected value »
I am looking to get minimum value from a list of maps in java. I am using combination of flatmap,stream and min to do so and not getting expected resu...
(2) odpowiedzi
2017-04-12 10:04 How to reduce list to map with Java functional API »
I want to transform a string of text to a dictionary, which contains all the unique words as a key, and translation as a value. I know how to transfo...
(3) odpowiedzi
2017-04-11 18:04 How to solve a control flow graph for pure expressions or functions? »
I have a simple, high-level assembly language, for which I can generate control flow graphs. I'm trying to solve/parse those control graphs for pure e...
(0) odpowiedzi