|
|
Search
You searched for the word(s): divisortheory
Showing page 1 of 6 (148 total posts)
< 1 second(s)
-
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.
-
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 ...
-
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 ...
-
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 ...
-
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 ...
-
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 ...
-
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
-
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 ...
-
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# ...
-
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
-
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 ...
-
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
-
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 ...
-
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 ...
-
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 ...
-
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 ...
-
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, ...
-
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) = ...
-
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 ...
-
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 ...
-
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 ...
-
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 ...
-
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 ...
-
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 ...
-
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 ...
1 ...
|
|