0

I have a question, am new to Ocaml THE functional programming. I have simple function of Ocaml which calculates a total of two numbers. Am using visual studio code. here is a sample of my function : let cubic a b = a + b ;; so, how do i run my the cmd line ? how do i type " cubic 3 3 " such that is returns 6

let cubic a b = a + b ;;
glennsl
  • 28,186
  • 12
  • 57
  • 75
Chung Lee
  • 13
  • 6
  • Have you installed Ocaml? Did you run it? Did you load the file? – Bergi Sep 10 '19 at 00:56
  • yes, i did stalled ocaml – Chung Lee Sep 10 '19 at 01:03
  • i have the Ocaml terminal but i don't wanna right my code there instead use Visual Studio code and run the program from the terminal. is that possible to do ? – Chung Lee Sep 10 '19 at 01:05
  • For that, you would have to write a cli program (which is certainly possible with Ocaml) and compile it, not just write a function. – Bergi Sep 10 '19 at 01:07
  • since am knew, i used to use vs code, because when I write the code i can easily fix it when i encounter an erro... but with Ocaml you to write a cli program - which requires you to get write before you run. ( do you know if there is a better approach when writing in cli ) – Chung Lee Sep 10 '19 at 01:14
  • I'm not sure we're on the same page here. What do you actually want, a program that you can run natively in the Windows command line? Or are you just looking for a way to quickly try out your functions during development, using a (terminal-like) REPL? – Bergi Sep 10 '19 at 01:38
  • am just looking for a way to quickly try out your functions during development, using a (terminal-like) REPL? --- this is what i want – Chung Lee Sep 10 '19 at 02:04
  • Sounds like you are looking for `UTop` then. It even integrates with the `OCaml` extension for vscode. – Bergi Sep 10 '19 at 02:07
  • i will check out.. Thank you – Chung Lee Sep 10 '19 at 02:16

0 Answers0