Skip to main content
Filter by
Sorted by
Tagged with
418 votes
15 answers
80k views

Is functional GUI programming possible? [closed]

I've recently caught the FP bug (trying to learn Haskell), and I've been really impressed with what I've seen so far (first-class functions, lazy evaluation, and all the other goodies). I'm no expert ...
218 votes
8 answers
26k views

In what areas might the use of F# be more appropriate than C#? [closed]

Over the last few years F# has evolved into one of Microsoft's fully supported languages employing many ideas incubated in OCaml, ML and Haskell. Over the last several years C# has extended its ...
146 votes
3 answers
22k views

Getting started with F# [closed]

How do I go about getting into F# programming? What are some good starter samples to learn the language, or learn about some of its advantages over other languages? What tools do I need (e.g. ...
Brian's user avatar
  • 119k
143 votes
5 answers
49k views

Difference between fold and reduce?

Trying to learn F# but got confused when trying to distinguish between fold and reduce. Fold seems to do the same thing but takes an extra parameter. Is there a legitimate reason for these two ...
Wallace's user avatar
  • 5,659
135 votes
9 answers
71k views

How to create a sequence of integers in C#?

F# has sequences that allows to create sequences: seq { 0 .. 10 } Create sequence of numbers from 0 to 10. Is there something similar in C#?
Budda's user avatar
  • 18.3k
135 votes
5 answers
33k views

What are the primary differences between Haskell and F#? [closed]

I've searched on the Internet for comparisons between F# and Haskell but haven't found anything really definitive. What are the primary differences and why would I want to choose one over the other?
ljs's user avatar
  • 37.7k
131 votes
3 answers
29k views

F# changes to OCaml [closed]

F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.
Erik Forbes's user avatar
  • 35.8k
128 votes
1 answer
23k views

Why is this F# code so slow?

A Levenshtein implementation in C# and F#. The C# version is 10 times faster for two strings of about 1500 chars. C#: 69 ms, F# 867 ms. Why? As far as I can tell, they do the exact same thing? Doesn't ...
Robert Jeppesen's user avatar
120 votes
4 answers
11k views

Best approach for designing F# libraries for use from both F# and C#

I am trying to design a library in F#. The library should be friendly for use from both F# and C#. And this is where I'm stuck a little bit. I can make it F# friendly, or I can make it C# friendly, ...
Philip P.'s user avatar
  • 2,384
117 votes
3 answers
23k views

Object initialization syntax

I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3. I.e. given this: public class Person { public DateTime BirthDate { get; set; } public string ...
Mauricio Scheffer's user avatar
116 votes
6 answers
11k views

Why are functions in OCaml/F# not recursive by default?

Why is it that functions in F# and OCaml (and possibly other languages) are not by default recursive? In other words, why did the language designers decide it was a good idea to explicitly make you ...
nsantorello's user avatar
  • 1,719
110 votes
10 answers
30k views

Haskell composition (.) vs F#'s pipe forward operator (|>)

In F#, use of the the pipe-forward operator, |>, is pretty common. However, in Haskell I've only ever seen function composition, (.), being used. I understand that they are related, but is there ...
Ben Lings's user avatar
  • 29.3k
108 votes
7 answers
19k views

F# development and unit testing? [closed]

I just got started with F#, which is my first functional language. I have been working quasi-exclusively with C#, and enjoy a lot how F# leads me to re-think how I write code. One aspect I find a bit ...
Mathias's user avatar
  • 15.3k
104 votes
3 answers
120k views

F# List.map equivalent in C#?

Is there an equivalent to F#'s List.map function in C#? i.e. apply a function to each element in the list and return a new list containing the results. Something like: public static IEnumerable&...
Andrew Jones's user avatar
  • 5,367
104 votes
1 answer
1k views

MbUnit under Linux, used within an F# project?

I tried asking this on the gallio-users list, but the question failed to appear (Google Groups says the post was successful). I suppose the list might be moderated by someone who does not read his ...
user1002059's user avatar
  • 1,525
103 votes
6 answers
20k views

How can I use functional programming in the real world? [closed]

Functional languages are good because they avoid bugs by eliminating state, but also because they can be easily parallelized automatically for you, without you having to worry about the thread count. ...
Brian R. Bondy's user avatar
99 votes
1 answer
18k views

What the difference between a namespace and a module in F#?

I've just started learning F# (with little prior experience with .NET) so forgive me for what is probably a very simple question: What the difference between a namespace and a module in F#? Thanks ...
Dave Berk's user avatar
  • 1,631
98 votes
7 answers
13k views

When are higher kinded types useful?

I've been doing dev in F# for a while and I like it. However one buzzword I know doesn't exist in F# is higher-kinded types. I've read material on higher-kinded types, and I think I understand their ...
lobsterism's user avatar
  • 3,509
94 votes
5 answers
19k views

F#: let mutable vs. ref

First, I acknowledge the possibility that this question could be a duplicate; just let me know. I'm curious what the general "best practice" is for those situations when mutability is desired. F# ...
J Cooper's user avatar
  • 17k
94 votes
5 answers
15k views

When to use a sequence in F# as opposed to a list?

I understand that a list actually contains values, and a sequence is an alias for IEnumerable<T>. In practical F# development, when should I be using a sequence as opposed to a list? Here's ...
dodgy_coder's user avatar
  • 12.8k
93 votes
8 answers
19k views

F# explicit match vs function syntax

Sorry about the vague title, but part of this question is what these two syntax styles are called: let foo1 x = match x with | 1 -> "one" | _ -> "not one" let foo2 = function ...
Benjol's user avatar
  • 66k
93 votes
8 answers
184k views

What are the benefits of using C# vs F# or F# vs C#? [closed]

I work for a tech company that does more prototyping than product shipment. I just got asked what's the difference between C# and F#, why did MS create F# and what scenarios would it be better than C#...
gradbot's user avatar
  • 13.8k
92 votes
5 answers
15k views

How do I use Travis-CI with C# or F#

Travis CI continuous integration service officially supports many languages, but not C# or F#. Can I use it with my .net projects?
jbtule's user avatar
  • 31.7k
89 votes
2 answers
13k views

What is the equivalent in F# of the C# default keyword?

I'm looking for the equivalent of C# default keyword, e.g: public T GetNext() { T temp = default(T); ... Thanks
elmattic's user avatar
  • 12.1k
87 votes
1 answer
4k views

Async POST fails on WP7 and F#

When I do let! read = from.AsyncRead buf in F#, it blocks and doesn't return until the TCP socket is dead. Why? And how do I fix it? Its code: module StreamUtil open System.IO /// copy from 'from' ...
Henrik's user avatar
  • 9,798
86 votes
5 answers
29k views

F# defining/using a type/module in another file in the same project

This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition Stack.fs namespace Col ...
JaredPar's user avatar
  • 750k
84 votes
4 answers
6k views

Is it possible to write a JIT compiler (to native code) entirely in a managed .NET language

I'm toying with the idea of writing a JIT compiler and am just wondering if it is even theoretically possible to write the whole thing in managed code. In particular, once you've generated assembler ...
J D's user avatar
  • 48.5k
82 votes
4 answers
49k views

Call F# code from C#

I am playing around with F# and C#, and would like to call F# code from C#. I managed to get it to work the other way around in Visual Studio by having two projects in the same solution, and adding ...
ZeroKelvin's user avatar
  • 1,943
81 votes
4 answers
11k views

Use of `inline` in F#

The inline keyword in F# seems to me to have a somewhat different purpose than what I'm used to in e.g. C. For example, it seems to affect a function's type (what are "statically resolved type ...
J Cooper's user avatar
  • 17k
79 votes
5 answers
43k views

What is the F# language created to accomplish?

I have noticed more and more a growing number of resources for developing applications using the F# programming language and the question came to mind of what the F# language was created to accomplish....
Edward's user avatar
  • 7,426
78 votes
2 answers
13k views

Best way to condense a list of option type down to only elements that are not none?

I'm unexpectedly having a bit of trouble with going from a list of 'a option down to a list containing only the elements that are Some. My initial attempt was: let ga = List.filter (fun xx -> ...
Tony Peterson's user avatar
78 votes
1 answer
6k views

Application architecture/composition in F#

I have been doing SOLID in C# to a pretty extreme level in recent times and at some point realized I'm essentially not doing much else than composing functions nowadays. And after I recently started ...
TeaDrivenDev's user avatar
  • 6,611
76 votes
11 answers
9k views

What are practical uses of applicative style?

I am a Scala programmer, learning Haskell now. It's easy to find practical use cases and real world examples for OO concepts, such as decorators, strategy pattern etc. Books and interwebs are filled ...
missingfaktor's user avatar
75 votes
9 answers
21k views

Explaining pattern matching vs switch [closed]

I have been trying to explain the difference between switch statements and pattern matching(F#) to a couple of people but I haven't really been able to explain it well..most of the time they just look ...
Nathan W's user avatar
  • 55.3k
74 votes
3 answers
21k views

Pattern matching on the beginning of a string in f#

I am trying to match the beginning of strings in f#. Not sure if I have to treat them as a list of characters or what. Any suggestions would be appreciated. Here is a psuedo code version of what I ...
Jeff's user avatar
  • 1,201
73 votes
10 answers
22k views

F# performance in scientific computing

I am curious as to how F# performance compares to C++ performance? I asked a similar question with regards to Java, and the impression I got was that Java is not suitable for heavy numbercrunching. ...
Anycorn's user avatar
  • 51.1k
72 votes
4 answers
7k views

What are advantages and disadvantages of "point free" style in functional programming?

I know that in some languages (Haskell?) the striving is to achieve point-free style, or to never explicitly refer to function arguments by name. This is a very difficult concept for me to master, ...
Eli Schneider's user avatar
72 votes
4 answers
16k views

Why does the power operator in F# only work for floating point numbers?

I have never seen a language have exponent or power operator only taking floating point numbers? For example: 2 ** 2 throws an error The type 'int' does not support any operators named 'Pow' Are ...
unj2's user avatar
  • 53.2k
71 votes
3 answers
15k views

Does (or will) C# include features for side-effects verification? [closed]

I know C# is getting a lot of parallel programming support, but AFAIK there is still no constructs for side-effects verification, right? I assume it's more tricky now that C# is already laid out. But ...
Joan Venge's user avatar
  • 328k
69 votes
6 answers
46k views

How read a file into a seq of lines in F#

This is C# version: public static IEnumerable<string> ReadLinesEnumerable(string path) { using ( var reader = new StreamReader(path) ) { var line = reader.ReadLine(); while ( line != ...
Yin Zhu's user avatar
  • 17.1k
68 votes
31 answers
13k views

Handy F# snippets [closed]

There are already two questions about F#/functional snippets. However what I'm looking for here are useful snippets, little 'helper' functions that are reusable. Or obscure but nifty patterns that ...
68 votes
4 answers
5k views

Why is F#'s type inference so fickle?

The F# compiler appears to perform type inference in a (fairly) strict top-to-bottom, left-to-right fashion. This means you must do things like put all definitions before their use, order of file ...
J Cooper's user avatar
  • 17k
67 votes
2 answers
18k views

F# vs OCaml: Stack overflow

I recently found a presentation about F# for Python programmers, and after watching it, I decided to implement a solution to the "ant puzzle" on my own. There is an ant that can walk around on a ...
ttsiodras's user avatar
  • 11.1k
66 votes
1 answer
3k views

How to marshal multi-dimensional arrays

We have some interop code that involves matrices. I was trying to call the native DLL and for the most part it works very reliably. I am relying on the default marshalling by .net, avoiding unmanaged ...
Daniel Fabian's user avatar
65 votes
14 answers
39k views

Units of measure in C# - almost

Inspired by Units of Measure in F#, and despite asserting (here) that you couldn't do it in C#, I had an idea the other day which I've been playing around with. namespace UnitsOfMeasure { public ...
Benjol's user avatar
  • 66k
65 votes
1 answer
15k views

What are the differences between in .fsx, .fsi and .fs file in F#?

So I'm starting to learn F# from the tryfsharp.org and I'm using VS2013. What are the differences of the .fs (source), .fsx (script) and .fsi (signature)?
Kenneth Bastian's user avatar
63 votes
3 answers
14k views

When should I use let, member val and member this.?

F# has many different ways to define variables/members in types. When should I use let, member val and member this. in F#, and what is the difference between them? How about static and mutable members?...
user avatar
63 votes
3 answers
40k views

C# / F# Performance comparison

Is there any C#/F# performance comparison available on web to show proper usage of new F# language?
Vijesh VP's user avatar
  • 4,540
63 votes
2 answers
8k views

Is F# really faster than Erlang at spawning and killing processes?

Updated: This question contains an error which makes the benchmark meaningless. I will attempt a better benchmark comparing F# and Erlang's basic concurrency functionality and inquire about the ...
Tristan's user avatar
  • 6,896
61 votes
7 answers
41k views

What's a functional replacement for if-then statements?

I've been learning F# and functional programming and trying to do things the functional way. However, when it comes to rewriting some code I'd already written in C# I get stuck at simple if-then ...
Bob's user avatar
  • 7,921

1
2 3 4 5
341