hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help

Search

You searched for the word(s): divisortheory
Showing page 1 of 6 (148 total posts) < 1 second(s)
  • Re: Best way to express this?

    brianmcn:mau was responding to eventhelix, who uses (<) instead of (>).And that's correct, isn't it? eventhelix preserved the semantics of divisortheory's code, whereas mau flipped it by not flipping the operator.So yes, I wholeheartedly agree with you. As long as F# doesn't support operator sections, it's not worth the hassle and confusion.
    Posted to How To's and Snippets (Forum) by Kha on March 10, 2010
  • Re: Best way to express this?

    divisortheory:I have to admit, I have no idea how this code works :)  What chapter(s) in Expert F# discusses such techniques?  Or if you have external links that discuss techniques such as this I'd be interested.Also, is there a technical limitation that prevents F# from supporting break/continue?  It seems like even if ...
    Posted to How To's and Snippets (Forum) by eventhelix on March 3, 2010
  • Re: advantage of programming parallel application in f# ( vs. c#) ?

    dbo:What would also be great to know, if anybody of you use f# to write ''common'' desktop applications? I often see expamles using f# in scientifc or mathematical areas, but is it also an good idea to write an normal deskop application with gui and lots of interactions with f#? Thanks for any help in advance. DanielI wrote such an app ...
    Posted to General Discussions on F# (Forum) by divisortheory on April 3, 2009
  • Re: How do I write an efficient array loop?

    Actually the IL method I had in mind turned out to be more compliacted than I thought.  For some reason I thought the initblk opcode took a 32-bit integer argument, but it's only 8 :(  Now that I think about it I'm not even sure why there isn't an IL opcode for initializing a block of memory with something other than a byte, x86 supports ...
    Posted to How To's and Snippets (Forum) by divisortheory on April 1, 2009
  • Re: Functional vs Imperative speed

    divisortheory:Some of the benchmarks for Haskell GHC are right up there.  In fact, the website originally had to redesign all of their tests because of Haskell GHC.  It was beating even the best languages by orders of magnitude, like tenfold due to laziness.  Laziness is one aspect that leads to higher performing code, another is ...
    Posted to How To's and Snippets (Forum) by jdh30 on March 28, 2009
  • Re: another match vs. if-then question

    divisortheory:Which takes an input list and a predicate, and if the predicate is true writes (f x) into the output sequence, and if the predicate is false writes nothing into the output sequence.  You could do this by doing List.filter followed by List.map, but this is going to be slow because you have to walk the list twice instead of just ...
    Posted to How To's and Snippets (Forum) by jhugard on March 24, 2009
  • Re: another match vs. if-then question

    This is a common mistake.  What it boils down to is that specifying an identifier on the left hand side of a match condition BINDS that symbol to the matched value.  It does not perform a comparison.  What I imagine you thought was going to happen is that in picker1, the first match condition would be executed if the head of the list
    Posted to How To's and Snippets (Forum) by divisortheory on March 23, 2009
  • Re: Straight to a discriminated union type from an object in a pattern match?

    divisortheory:Also, in your original example it will also throw, just that it will throw a MatchFailureException instead of a casting exception if it's not of type A.  I guess you could argue that adding a catchall handler at the end of the match block (i.e. | _ -> (*do something*)) is more readable and more ''functional'' than the ...
    Posted to General Discussions on F# (Forum) by banshee on March 17, 2009
  • Re: When can we expect the next F# release?

    felixmar:Mono is one platform, but also Silverlight, Azure etc. Licensing issues aside i would like an easy way to recompile (parts of) FSharp.Core for those platforms. Right now it is not clear if it is even possible to recompile the released F# source code for the regular .NET framework. To be honest issues like this make me hesitant to use F# ...
    Posted to General Discussions on F# (Forum) by DannyAsher on March 17, 2009
  • Re: Functional vs Imperative speed

    Isaac Gouy: divisortheory:You'll notice there are half a dozen C and C++ programs also considered not to have followed the rules which only took 0.1s - 0.6s.I make mistakes too.I copied the wrong column - there are half a dozen C and C++ programs also considered not to have followed the rules which only took 0.26s - 1.60s compared to 3.07s
    Posted to How To's and Snippets (Forum) by Isaac Gouy on March 13, 2009
  • Re: Functional vs Imperative speed

    Definitely a two way street, if it were a one way street there'd be provably no reason to use imperative languages :)  Yea you can always add a node to the front of a linked list in an imperative language, but the only point I was really trying to make is that in a functional setting the same memory is re-used by default, whereas in an ...
    Posted to How To's and Snippets (Forum) by divisortheory on March 11, 2009
  • Re: Can't we leave VB behind?

    FSEnthusiast:Well, the reason I picked the semicolon character while stating that F# could've used it to end statements is that I can see that F# has elements of C/C++ in it, like printf and the underscore embedded in certain keywords (or library functions, or whatever). And C/C++ use semicolons to end statements, which is certainly a more precise
    Posted to General Discussions on F# (Forum) by divisortheory on March 10, 2009
  • Re: A suggestion to allow writing performance-optimal code in F#

    brianmcn:A note of caution: beware measurements of anything other than Release-mode optimized code.  Measuring well is not always trivial.That reminds me.  In the Visual Studio Project options, there's a way to specify ''compilation flags'' for F# interactive.  One of the default ones is --optimize.  Does this mean that FSI ...
    Posted to General Discussions on F# (Forum) by divisortheory on February 24, 2009
  • Re: Stack overflow with Sieve of Eratosthenes

    I actually suspected this might be the culprit, but wanted to wait until you or someone more knowledgeable replied :P  I thought it might be a decent solution to instead of writing the function ''sieve_multiples_of p'', make it ''sieve_multiples_up_to p primes'', and have primes be a list of all primes found so far.  But a cursory ...
    Posted to How To's and Snippets (Forum) by divisortheory on February 24, 2009
  • Re: Luhn checking algorithm and customised forward pipe operator

    One way to pipeline to parameters other than the last parameter is to pipe it to an anonymous function to reorder the variables for you.For example:[code language=''F#'']let func x y z = ()''hello'' |> (fun str -> func 1 str 2)[/code]In reality it doesn't matter which argument the pipeline operator ends up piping to, there will always be a ...
    Posted to How To's and Snippets (Forum) by divisortheory on February 23, 2009
  • Re: Rewrite a seq expression to remove a mutable

    Hi.I had an identical problem a few weeks ago.  Here is a lazy list implementation of the prime number sequence:[code language=''F#'']let rec smallest_prime_factor n =     let limit = System.Math.Sqrt(float(n)) |> int    let rec smallest_prime_factor primes =         match ...
    Posted to How To's and Snippets (Forum) by divisortheory on February 19, 2009
  • Re: Problem with delegate

    Hmm.  Using System.EventHandler (which seems like what you want, a delegate that takes 2 arguments) as an example, you can write the following code in C#.[code language=''C#'']void f(object arg1, System.EventArgs arg2) {}void g(){    System.EventHandler handler = new System.EventHandler(f);}[/code]So if I understand correctly, ...
    Posted to How To's and Snippets (Forum) by divisortheory on February 18, 2009
  • Re: Event chaining question

    Finally got something I'm satisfied with.  I have to say, I really just absolutely love the whole idea of event composition in F#.  It takes some time to adjust your thinking, but it's very elegant when you get a good solution.This is what I finally came up with:[code language=''F#'']let track_selection_rect (c:#Control) = ...
    Posted to How To's and Snippets (Forum) by divisortheory on February 17, 2009
  • Re: Calling a function from an object constructor

    Thanks!  I had figured out that I could access base members via base.x, and that gave me everything I needed except being able to add an event handler to the object during initialization.  It was an inherited windows form, and I wanted the form to handle the Activated event, and it wouldn't let me do this through base.  Naming the ...
    Posted to How To's and Snippets (Forum) by divisortheory on February 17, 2009
  • Re: getting nth element from seq - beginner question

    Convert it to a list first.let position = tsorted |> Seq.to_list |> List.find_index (fun value -> value=name)or a bit shorter:let position = tsorted |> Seq.to_list |> List.find_index ((=) name)Which is basically using partial function applicatino.  The = operator can be treated like a function.  So normally = takes two ...
    Posted to General Discussions on F# (Forum) by divisortheory on February 7, 2009
  • Re: Computing probability via recursion

    divisortheory:Just out of curiosity, how would you write such a definition of memoize?Like this [code language=''F#'']#light#nowarn ''40''open System.Collections.Genericmodule Memo=   let Cached f=   let cache=new Dictionary<_,_>()     fun a -> match cache.TryGetValue a with              | true, result -> result ...
    Posted to Algorithms and Data Structures (Forum) by brilsmurf on February 3, 2009
  • Re: suggestion: Type inference helper

    Sounds like all of the things I've been trying whenever problems arise :)  It usually works pretty well, but sometimes I still scratch my head over these problems.  Anyway, mostly I just wanted to throw this out there, it's highly unlikely I'll come across anything groundbreaking that someone on the team hasn't already thought of, but ...
    Posted to General Discussions on F# (Forum) by divisortheory on February 1, 2009
  • Re: Function composition question

    divisortheory:Hmm, yea I guess that works, perhaps the way i aws doing it was already the most elegant Well, you could drop the parens, because function-calls bind more tightly than logical operations: [code language=''F#'']let f x = x>1let g x = x<3let h x = f x && g x[/code] See Precedence and Operators in the F# Draft ...
    Posted to How To's and Snippets (Forum) by jhugard on January 30, 2009
  • Re: Multiple files

    Thanks, I was actually trying all of that but the auto-generated module name was apparently being tricky.  I'm still not sure what it auto-generated as, but my file was of the format abc_def.fs where all letters were lowercase.  This still seems weird, because all of the following work://top of filemodule a//code//top of filenamespace ...
    Posted to How To's and Snippets (Forum) by divisortheory on January 30, 2009
  • Re: Difficult recursive function problem

    Wow, somehow I actually got it.  Funny that I'd been working on it for hours, and then like 30 minutes after posting I came up with a solution:That being said, it's not terribly efficient.  If someone could suggest any optimizations I'd appreciate it.  I'm pretty sure it's correct[code language=''F#'']let match_multi ...
    Posted to How To's and Snippets (Forum) by divisortheory on January 28, 2009
1 2 3 4 5 Next > ... Last »
Powered by Community Server, by Telligent Systems