Data dodania Pytanie
2017-02-18 22:02 Generalizing DivisibleBy in type-level programming with Scala »
I'm trying to generalize a divisible-by relation in Scala using type level programming. This is my Nat number definitions: trait Nat { type plus[N&...
(1) odpowiedzi
2017-02-18 18:02 F# tree-building function causes stack overflow in Xamarin Studio »
I'm trying to build up some rules in a tree structure, with logic gates i.e. and, not, or as well as conditions, e.g. property x equals value y. I wro...
(1) odpowiedzi
2017-02-18 18:02 Why is .array necessary after .group to use .sort? »
Having the following piece of code: import std.algorithm : filter, canFind, map, splitter, group, sort; import std.stdio : File, writefln; import std...
(1) odpowiedzi
2017-02-17 21:02 Functional way to find a pair of integers, which sum to X, in a sorted array »
This is a follow-up to my previous question. Suppose I want to find a pair of integers, which sum to a given number x, in a given sorted array. The we...
(4) odpowiedzi
2017-02-17 09:02 How to judge whether a list is a sub sequence of another with java8 stream? »
For example, I have a long list [1, 2, 3, ..., 10], and a short one [1, 3, 6], then I can tell that the short one is the subsequence of another. On th...
(5) odpowiedzi
2017-02-17 04:02 Evaluation of where clause in cyclic lists »
In Thinking Functionally in Haskell (p 213), we're shown two versions of a cyclic list. One evaluates in quadratic time: iterate3 f x = x:map f (iter...
(2) odpowiedzi
2017-02-16 16:02 java8 stream style for retrieving a inner part of map through a field list? »
For example, given a map like below: { "k1": { "k2": { "k3": { "k4": "v" } } } } and a field list ["k1","k2","k3"],...
(2) odpowiedzi
2017-02-16 14:02 Scala way of applying function to list and getting highest result with input »
best_acc = 0 for split in split_candidates: acc = self.get_split_score(t_series_distances, split) if acc > best_acc: best_acc = acc...
(1) odpowiedzi
2017-02-16 12:02 How to traverse array from both left to right and from right to left? »
Suppose I have an imperative algorithm that keeps two indices left and right and moves them from left to right and from right to left var left = 0 v...
(3) odpowiedzi
2017-02-15 23:02 Partially applying <*> with zip »
I started to look at some Haskell code and found: foo :: ([a] -> [b]) -> [a] -> [(a, b)] let foo = (<*>) zip I don't understand how ...
(1) odpowiedzi
2017-02-15 20:02 Swap two array elements in a functional way »
I'm trying to swap 2 elements within an array in a functional way in javascript (es6) let arr = [1,2,3,4,5,6] let result = swap(arr, 1, 2) // input: ...
(6) odpowiedzi
2017-02-15 18:02 java8 stream style to convert a key-value list to a map? »
I want to convert a list like [k1, v1, k2, v2] to a map like {k1: v1, k2: v2}. The original code is: List<Object> params = Arrays.asList("k1", ...
(2) odpowiedzi
2017-02-14 22:02 How to reduce/transform an array of objects to result in the aggregate sum of each property (lodash ideally) »
I have an array of nutrition object that look something like this: [ { calories: {total: 0, fat: 0}, vitamins: {a: {total: 0, retinol: 0}, ...
(4) odpowiedzi
2017-02-14 10:02 How to use javascript reduce function for objects in an array to get string values »
I have an array of objects from which I would like to get names. I am trying to use reduce for that but the problem is that reduce returns the first ...
(5) odpowiedzi
2017-02-14 09:02 Can we deconstruct arbitrary data constructors? »
In Haskell, or any other programming language supporting pattern matching, can we achieve the following: Given a data constructor e.g. Left :: a -&gt...
(1) odpowiedzi
2017-02-13 22:02 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 ru...
(0) odpowiedzi
2017-02-13 08:02 Use attributes for value tuples »
In C# 7.0, .NET introduces a new return value tuple types (functional programming), so instead of: [NotNull] WrapperUser Lookup(int id) I'd like to...
(0) odpowiedzi
2017-02-13 00:02 Can't change/establish root binding of: [some-def] with set in Clojure »
I could not set my dynamic var's value to new one. (def *pop* true) (set! *pop* false) => IllegalStateException Can't change/establish root bind...
(2) odpowiedzi
2017-02-12 14:02 What does it mean that functional languages provide explicit data structure representations? »
I'm read chapter 1.13 AN INTRODUCTION TO FUNCTIONAL PROGRAMMING THROUGH LAMBDA CALCULUS and see it. What is the "explicit data structure representatio...
(1) odpowiedzi
2017-02-12 13:02 How to make a map from array of object? »
Each object has a 'id' property, and I want to make a 'id' => object map. This is easy via Guava in java world. How to do it in PHP easily? e.g. func...
(1) odpowiedzi
2017-02-12 05:02 How to understand the execution of this Haskell program? »
While I was studying the foldr function in Haskell I came across this program and I am not able to figure out how it is executing. mylength :: [ Int ...
(1) odpowiedzi
2017-02-11 22:02 F# - Uppercase the first string in a list »
In my code showen below I am trying to change the first letter of the first string to uppercase and also set a question mark: let strList = ["are"; "...
(1) odpowiedzi
2017-02-11 20:02 Currying vs. anonymous function in Scala »
I was comparing two ways of defining a higher-order function in Scala: def f1(elem: Int)(other: Int) = (elem == other) def f2(elem: Int) = (other: I...
(1) odpowiedzi
2017-02-11 02:02 Why (function(){return this}).bind(1).bind(2)() returns 1? »
Why this returns 1 instead of expected 2? (function() { return this }) .bind(1) .bind(2)() Looked up Mozilla's bind reference, but it did no...
(0) odpowiedzi
2017-02-10 20:02 Mathematic sequence further elements »
Let's say I have following equation . My goal is to create sequence which returns next elements of this. Here's my solution and it works: let rec fac...
(2) odpowiedzi
2017-02-10 17:02 How to reconcile Javascript with currying and function composition »
I love currying but there are a couple of reasons why a lof of Javascript devs reject this technique: aesthetic concerns about the typical curry pat...
(2) odpowiedzi
2017-02-10 01:02 Why `id id` is not a value in OCaml? »
I am still trying to understand the value restriction in OCaml and I was reading through Wright's paper. And in it states (fun x -> x) (fun y ->...
(2) odpowiedzi
2017-02-09 15:02 'tee' operation on Scala's option type? »
Is there some sort of 'tee' operation on Option in Scala's standard library available? The best I could find is foreach, however its return type is Un...
(3) odpowiedzi
2017-02-09 14:02 How can i correct this error in functionnal programming? »
on the 44th line it gives me a type error Type automate is not compatible with type Format.formatter im trying to draw an automaton using graphviz her...
(1) odpowiedzi
2017-02-09 09:02 Collecting items with Kotlin streams »
I have a Player that has Bags, and each Bag has items (String): class Player(val bags: List<Bag>) class Bag(val items: List<String>) I ...
(1) odpowiedzi
2017-02-08 19:02 Scala: Lensing vs mutable design »
My basic understanding of lensing is that, "a lens is a value representing maps between a complex type and one of its constituents. This map works bot...
(1) odpowiedzi
2017-02-08 17:02 Is there a fast, functional prime generator? »
Suppose I've got a natural number n and I want a list (or whatever) of all primes up to n. The classic prime sieve algorithm runs in O(n log n) time ...
(2) odpowiedzi
2017-02-08 02:02 Scala streams with array/vector performance characteristics »
I am taking a class on algorithms, and I'm solving a few exercises on dynamic programming right now. I looked up how I would solve some of the proble...
(1) odpowiedzi
2017-02-07 20:02 functional composition of a boolean 'not' function (not a boolean value) »
I am working in TS but will show the tsc -> ES6 code below. I have a function 'isDigit' that returns true if the the character code is in the range o...
(1) odpowiedzi
2017-02-07 18:02 List of lists, lamba and filtering results »
I want to create two functions: 1) function which finds all elements less than zero in list (int list list) and then return these elements as list of ...
(1) odpowiedzi