Related news

Published: 23/06/2018Say for example you want to use two Integrals mod and div and you want to use a the logic operator  Baby n  n < 0 = 0  (n `mod` 10)  (n `div` 10) /= 3 = 0 How are you able to use the Or funct ... Read moreSource: stackoverflow.com


Published: 23/06/2018I'm learning Haskell. Average of large number of Dice Rolls in Haskell How shall I make the below code work with multiple dices say 8 dices) instead of repeatedly creating let rolls..3,4,5...etc... mo ... Read moreSource: stackoverflow.com

Published: 23/06/2018I am wondering if one can write a functional program (as in Haskell or OCaml) that takes two lists and determines if the first is a sublist of the second, with the property that the program cannot inv ... Read moreSource: stackoverflow.com

Published: 22/06/2018I'm having a bit of trouble parsing this. But as I write it out, I think I may have it. let add = { __functor = self: x: x + self.x; }; inc = add // { x = 1; }; in inc 1 First, is self a keyword like ... Read moreSource: stackoverflow.com

Published: 22/06/2018I have this JSON code { "cod": "200", "message": 0.0205, "cnt": 40, "list": [{ "dt": 1529690400, "main": { "temp": 294.89, "temp_min": 289.889, "temp_max": 294.89, "pressure": 875.6, "sea_level": 1022 ... Read moreSource: stackoverflow.com

Published: 22/06/2018I want to display a graph layed out by graphviz (via Data.GraphViz ) in a Gtk window. The code I have does not automatically center the graph or size the diagram. I have setup a github repo with an ex ... Read moreSource: stackoverflow.com

Published: 22/06/2018I'm following the Real World Haskell book. In the chapter about Monads, they give a simple example using the list monad to compute all pairs of numbers (x, y) that such that x * y == n . Their solutio ... Read moreSource: stackoverflow.com

Published: 22/06/2018I have the following function g g :: Int > Int > Int g x y = x + y * y I use g in the following three ways but don't quite understand what they each do. map (g 10) [1,2,3,4,5]  1 map (10 ‘g‘ ... Read moreSource: stackoverflow.com

Published: 22/06/2018Input is a list of words. If a word's last letter is the same as the first letter of another word, then we connect them and output a list of lists, which contain all possible connections. I convert th ... Read moreSource: stackoverflow.com

Published: 22/06/2018Please help me understand the below haskell code. data Coin = Heads  Tails deriving ({hi}Eq, {/hi} Show,Enum,Bounded) instance Random Coin where randomR (a,b) g = case randomR (fromEnum a, fromEn ... Read moreSource: stackoverflow.com

Published: 22/06/2018I've been doing some work building my own custom prelude and I wanted to build a Callable type class that would implement function application ( ($) ) for types other than functions. So I built a type ... Read moreSource: stackoverflow.com

Published: 22/06/2018Philip Wadler's paper "Monads for functional programming" has an example of a function eval which performs division written in Haskell. Here it is as adapted in "Programming in Haskell" by Graham Hutt ... Read moreSource: stackoverflow.com

Published: 22/06/2018I've found that using me$ stack install resolver lts11.0 on the snippet {# LANGUAGE NoImplicitPrelude #} {# LANGUAGE OverloadedStrings #} module Main where import ClassyPrelude import Network.H ... Read moreSource: stackoverflow.com

Published: 22/06/2018I'm trying to create a type signature for a function in template haskell. Is there an easy way of doing this? I've done some workarounds to solve it in the meantime, but it should be easier, right?  ... Read moreSource: stackoverflow.com

Published: 21/06/2018How can this function return true? foldr () False [True,undefined] => True The first fold looks like this: undefined  True , which should return an error So im guessing haskell gives priority t ... Read moreSource: stackoverflow.com

Published: 21/06/2018This question already has an answer here: Cartesian product of 2 lists in Haskell 12 answers I know how to use list comprehension to do this, but how can I implement a function that will recursively c ... Read moreSource: stackoverflow.com

Published: 21/06/2018I downloaded and installed Platform 8.4.3 as a pkg from the https://www.haskell.org/platform/ . This is what I get when I try to run ghci immediately afterwards. $ ghci dyld: Library not loaded: /usr/ ... Read moreSource: stackoverflow.com

Published: 21/06/2018What's the priority of :: , is there any operator has even lower priority than it? It seems the priority of :: is lower than $ , because both of the expression below returns "ab" map head $ ["alice", ... Read moreSource: stackoverflow.com

Published: 21/06/2018To implement a visualized arithmetic expression editor in Haskell, I defined the following things: data AST = Lit Int  Add AST AST  Neg AST eval :: AST > Int type TagName = String type Attrs = M ... Read moreSource: stackoverflow.com

Published: 21/06/2018I want to substitute a specific AST node into another, and this substituted node is specified by interactive user input. In nonfunctional programming, you can use mutable data structure, and each AST ... Read moreSource: stackoverflow.com

Published: 21/06/2018I'm using the Haskell code below to get the OpenGL world coordinates from the mouse coordinates (the code is a bit long but this is a minimal code to draw a cube). My expectation is that the function ... Read moreSource: stackoverflow.com