Niche Website Success will show you how to take your knowledge and build a themed, content website that can generate money through affiliate marketing, Google ads and more. Get it now!
First, the project you describe sounds (and I believe this is the correct legal term) totally freaking awesome Second, while F# is a good choice for math applications, its also extremely well-suited for any applications which perform a lot of symbolic processing. Its worth noting that F# is part of the ML family of languages which were originally designed for the specific purpose of developing theorem provers. It sounds like you're writing an application which appeals directly to the niche ML languages are geared for I would personally recommend writing any theorem proving applications you have in F# rather than C# -- only because the resulting F# code will be about 1/10th the size of the C# equivalent.
I posted this sample demonstrating how to evaluate propositional logic in C# and F#, you can see the difference for yourself.
First, the project you describe sounds (and I believe this is the correct legal term) totally freaking awesome. Second, while F# is a good choice for math applications, its also extremely well-suited for any applications which perform a lot of symbolic processing. Its worth noting that F# is part of the ML family of languages which were originally designed for the specific purpose of developing theorem provers.It sounds like you're writing an application which appeals directly to the niche ML languages are geared for.
I would personally recommend writing any theorem proving applications you have in F# rather than C# -- only because the resulting F# code will be about 1/10th the size of the C# equivalent. I posted this sample demonstrating how to evaluate propositional logic in C# and F#, you can see the difference for yourself.
Thanks Juliet I do hope it becomes an awesome project. That sample of yours opened my eyes. Since I can clearly see your point regarding propositional logic I'd like to know your thoughts on the other issue.
Would you care to comment on text processing and F#? – dde Jun 30 '09 at 3:34 F# actually comes with a Bison-like lexer/parser (I wrote this tutorial on parsing SQL: en.wikibooks. Org/wiki/F_Sharp_Programming/Lexing_and_Parsing), but I get the feeling the text parsing your doing doesn't conform to regular grammar.
You might end up writing your own state machine for this task, so I'm not 100% sure that F# will make the job any easier than C#. However, I really love F#'s pattern matching -- you can mix pattern matching and string parsing together for interesting results: en.wikibooks. Org/wiki/F_Sharp_Programming/… – Juliet Jun 30 '09 at 12:00 Thanks for your reply, it helped and pointed me to a great reading material on Lexing and Parsing.
The book is Apress' Expert F# by Don Syme et al, chapter 16. – dde Jul 3 '09 at 12:26.
Porting from prolog to F# won't be that straight forward. While they are both non-imperative languages. Prolog is a declarative language and f# is functional.
I never used C# Prolog libraries but I think it will be easier then converting the whole thing to f#.
1 You are right that a port from Prolog to F# won't be straightforward. But if you have C# Prolog libraries, it'd probably be easier to use those libraries from F# and write all the new code in F#. – Nathan Sanders Jun 29 '09 at 12:58 Right, won't be straightforward, however, as it is the program only evaluates whatever input to true or false.
The whole program is like one big function, with its inner functions,and they always return true/false. And, the whole point of the program is to win the debate either by keeping on the True track of the argumentation or by making the other party withdraw which is interpreted as True for one side and False for the other. This is why I need to evaluate arguments that are not so black and white.
I agree with Nathan, I can call C# Prolog from F#. – dde Jun 30 '09 at 3:49.
F# has many features that make this type of logic processing natural. To get a feel for what the language looks like, here is one possible way to decide which side of an argument has won, and by how much. Uses a random result for the argument, since the interesting (read "very hard to impossible") part will be parsing out the argument text and deciding how persuasive it would be to an actual human.
/// Declare a 'weight' unit-of-measure, so the compiler can do static typechecking type weight /// Type of tokenized argument type Argument = string /// Type of argument reduced to side & weight type ArgumentResult = | Pro of float | Con of float | Draw /// Convert a tokenized argument into a side & weight /// Presently returns a random side and weight let ParseArgument = let rnd = System.Random() let nextArg() = rnd.NextDouble() * 1.0 fun (line:string) -> // The REALLY interesting code goes here! Match rnd. Next(0,3) with | 1 -> Pro(nextArg()) | 2 -> Con(nextArg()) | _ -> Draw /// Tally the argument scored let Score args = // Sum up all pro & con scores, and keep track of count for avg calculation let totalPro, totalCon, count = args |> Seq.
Map ParseArgument |> Seq. Fold (fun (pros, cons, count) arg -> match arg with | Pro(w) -> (pros+w, cons, count+1) | Con(w) -> (pros, cons+w, count+1) | Draw -> (pros, cons, count+1) ) (0.0, 0.0, 0) let fcount = float(count) let avgPro, avgCon = totalPro/fcount, totalCon/ fcoun let diff = avgPro - avgCon match diff with // consider Draw | d when d > 0.0 -> Pro(d) | d -> Con(-d) let testScore = "yes"; "no"; "yes"; "no"; "no"; "YES! "; "YES!" |> Score printfn "Test score = %A" testScore.
It sounds like the functional aspects of F# are appealing to you, but you wonder if it can handle the non-functional aspects. You should know that F# has the entire . NET Framework at its disposal.It also is not a purely functional language; you can write imperative code in it if you want to.
Finally, if there are still things you want to do from C#, it is possible to call F# functions from C#, and vice versa.
Yes, this may be a lifesaver if things get nasty by trying to do everything in F#. – dde Jun 30 '09 at 3:56.
While F# is certainly more suitable than C# for this kind of application since there're going to be several algorithms which F# allows you to express in a very concise and elegant way, you should consider the difference between functional, OO, and logic programming. In fact, porting from F# will most likely require you to use a solver (or implement your own) and that might take you some time to get used to. Otherwise you should consider making a library with your prolog code and access it from .
NET (see more about interop at this page and remember that everything you can access from C# you can also access from F#).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.