This is a challenge to come up with the most elegant JavaScript, Ruby or other solution to a relatively trivial problem. This problem is a more specific case of the Longest common substring problem. I need to only find the longest common s...

I wrote a simple curry function in JavaScript which works correctly for most cases: const add = curry((a, b, c) => a + b + c); const add2 = add(2); const add5 = add2(3); console.log(add5(5)); <script> const curried = Symbol("curr...

Is there a reasonably fast way to extract the exponent and mantissa from a Number in Javascript? AFAIK there's no way to get at the bits behind a Number in Javascript, which makes it seem to me that I'm looking at a factorization problem: fi...

In my Yesod project i have the following route: /api/hide/thread/#Text/#Int ApiHideThreadR GET I want to request it on the client side with javascript: function hideThreadCompletely(threadId, board) { $.getJSON("/api/hide/thread/&#...

I have an element of type Data.Vector.Unboxed.Vector Word32. I want to convert that to a native JS TypedArray (an Uint32Array, specifically). I'm aware of toJsArray and toJsValListOf, but both functions deal with lists, not vectors, and are ineff...

Still most potential for a GUI to Haskell for me, but missing some essential info in the examples, being a noob Haskeller. Assuming one of the examples: {- webviewhs (C) 2018 David Lettier lettier.com -} {-# LANGUAGE OverloadedStrings #-...

I'd like to understand the original meaning of functional reactive programming in Haskell and how it differs from the actual application of FRP in Javascript. Unfortunately, I have only a superficial understanding of Haskell and have to stick wit...

How do I import in GHCJS a Javascript function like the following ? xs.subscribe(function(x) { console.log(x) }) I tried various combinations of the following without success: data Observable_ data Disposable_ type Observable a = JSRef Observabl...

The expression -1 % 7 in JavaScript is giving me -1 as the result. Whereas in Python and Haskell, I found the result to be 6. Can anyone explain why both have different behaviors? Which one is correct?...

A while ago, I posted a question on StackOverflow showing that the native implementation of reduceRight in JavaScript is annoying. Hence, I created a Haskell-style foldr function as a remedy: function foldr(array, callback, initial) { var length...

©2020 All rights reserved.