Are any Javascript engines tail call optimized?
I have a tail recursive pathfinding algorithm that I've implemented in Javascript and would like to know if any (all?) browsers would possibly get stack overflow exceptions. ...
I have a tail recursive pathfinding algorithm that I've implemented in Javascript and would like to know if any (all?) browsers would possibly get stack overflow exceptions. ...
I'm sketching a design of something (machine learning of functions) that will preferably want a functional programming language, and also introspection, specifically the ability to examine the program's own code in some nicely tractable format, and preferably also the ability to get machine generated code compiled at runtime, and I'm won...
I'm writing a python command line program which has some interdependent options, I would like for the user to be able to enter the options in whichever order they please. Currently I am using the getopts library to parse the command line options, unfortunately that parses them in-order. I've thrown together a system of boolean flags to...
haskell programmer. using F#. no typeclasses in F#. what to use when I need typeclasses? ...
I was playing around with this code kata in Haskell, and I came across the question in the topic. It's trivial to find the midpoint of an array whose indexes are a single numerical value, but Haskell's array indexes can be any instance of the Ix typeclass, including, for example, the tuple (Int, Word, Card) where card is an instance of ...
Using visual studio 2008 with the tr1 service pack and Intel C++ Compiler 11.1.071 [IA-32], this is related to my other question I'm attempting to write a functional map for c++ which would work somewhat like the ruby version strings = [2,4].map { |e| e.to_s } So i've defined the following function in the VlcFunctional namespace te...
Hello, Consider the interface: type IVector = abstract Item : int -> float Now, let us define the class: type DenseVector(size : int) = let mutable data = Array.zeroCreate size interface IVector with member this.Item with get n = data.[n] What about supply a method to mutate the n-th entry of the dense vect...
Hello F# folks, Suppose we have a Matrix class in F# and you overload the (+) operator. Then, we will have something like this: type Matrix(n : int, m : int) = ... static member (+) (A : Matrix, B : Matrix) = let res = new Matrix(A.Dim1, A.Dim2) // suppose A and B have the same dimension ... // compute here th...
Hi Guys. I need some help on simplifying my method I have this method public double ComputeBasicAmount(double basicLimit, double eligibleAmt) { return basicLimit * eligibleAmt; } sample usage: Foo foo = new Foo(100, 1000); double basicAmt = ComputeBasicAmount(foo.BasicLimit, foo.EligibleAmt) The problem here is I want the eligib...
Are the functions accumulate, compress, fold & reduce synonyms? ...
Hi Guys.. I have this two objects class RNB { public RNB(double roomRate, double roomDays) { RoomRate = roomRate; RoomDays = roomDays; } public double RoomRate { get; set; } public double RoomDays { get; set; } public const double BasicLimit = 100; } ...
I can understand how to create and think about the SKI and BCKW calculus, but I am never able to find practical uses. Maybe I am not looking deeply enough? That is, I wonder if (an example only please, I am not implying this is true) Java Servlets use S extensively and Python generators are an example of BCW and I am just unable to see...
I am building a node.js app and wondering which javascript lib to add to my repertoire. Current short list includes: Underscore wu Functional Bonus points for something that works in the browser (so I can use it on both client and server). Any ideas? Advice? Opinions on the above? Something else I should investigate? ...
Coming to OCaml from Lisp, I find myself very confused about when functions return and when they don't. I miss my magic Quote! Thankfully, most of the time, OCaml appears to automagicly know when I want a function evaluated and when I don't. However, I frequently find myself trying to assign the return value of a function in a let exp...
Say you have some list L and you want to split it into two lists based on some boolean function P. That is, you want one list of all the elements l where P(l) is true and another list where P(l) is false. I can implement this in Python like so: def multifilter(pred,seq): trues,falses = [],[] for x in seq: if pred(x): ...
I just got my copy of Expert F# 2.0 and came across this statement, which somewhat surprised me: For example, when necessary, you can use side effects on private data structures allocated at the start of an algorithm and then discard these data structures before returning a result; the overall result is then effectively a...
Im looking for an elegant way in Scala to split a given string into substrings of fixed size (the last string in the sequence might be shorter). So split("Thequickbrownfoxjumps", 4) should yield ["Theq","uick","brow","nfox","jump","s"] Of course I could simply use a loop but there has to be a more elegant (functional style) soluti...
Hello Everyone. I am trying to create a little functional programming library for Java (just to scratch my own itch). While defining the higher-order functions for Lists, Sets and Maps I have come across this problem: The functions that take a collection, and return a collection of same type have almost the same implementation, and yet ...
I have a problem with compiling a program written in ocaml, the error appears to me is: Error: Unbound module Basics, how can I solve this problem? I state that the beginner with this language. libraries used throughout the code are: open Basics ;; open Paritygame ;; open Univsolve;; open Solvers;; f...
According to wikipedia: functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. (emphasis mine). Is this really true? My personal understanding is that it makes the state more explicit, in the sense that programming is essentially applying fu...