6
 let GetVal (i,isMin,al, be)= 
        let b = new Board(board) 
        if b.SetBoardBool(i) then this.MinMaxAlphaBeta(b, isMin, al, be)
        else -2

    let valList = seq{ 
            for i =0 to 8 do 
                yield (GetVal i (not isMin) alphaF betaF ,  not isMin)
                } 

I am getting an F# error saying: This value is not a function and cannot be applied.

valList is sequence of tuples of int and bool and GetVal takes int bool int int and returns int. where alphaF betaF are mutable variables.

Mark Pattison
  • 2,964
  • 1
  • 22
  • 42
Taufiq Abdur Rahman
  • 1,348
  • 4
  • 24
  • 44
  • 1
    I think you'd be far better served to buy a good F# book and read it and work through the exercises in the book. Trying to learn F# by hacking on code without really understanding what the code is doing is probably a waste of your time and ours. – Onorio Catenacci Oct 06 '13 at 18:30
  • By the way, using magic numbers http://en.wikipedia.org/wiki/Magic_number_(programming) in code is generally a bad practice and one you should avoid where possible. What does -2 mean in the code above? – Onorio Catenacci Oct 06 '13 at 18:34

2 Answers2

4

Or you could change the signature of GetVal to not pass a tuple--like this:

let GetVal i isMin al be =

i, isMin, al, and be are called curried parameters. You can find more detail here under the topic "Partial Application of Arguments." I would post a direct link but there doesn't seem to be one.

Onorio Catenacci
  • 14,928
  • 14
  • 81
  • 132
2

Your GetVal function takes tupled arguments (a,b,c,d) whilst you call it with curried arguments a b c d

Something like this should work

yield (GetVal (i, (not isMin), alphaF, betaF) ,  not isMin)
John Palmer
  • 25,356
  • 3
  • 48
  • 67
  • i get this error now. The mutable variable 'betaF' is used in an invalid way. Mutable variables cannot be captured by closures. Consider eliminating this use of mutation or using a heap-allocated mutable reference cell via 'ref' and '!' – Taufiq Abdur Rahman Oct 05 '13 at 14:23
  • I can't tell from the code you've posted but I'm guessing you created betaF like this: val mutable betaF. The yield in this case is a closure. Look at the answers to this question http://stackoverflow.com/questions/3221200/f-let-mutable-vs-ref And for goodness sake, buy a good F# reference and read it. – Onorio Catenacci Oct 06 '13 at 18:33