Any F# programmers out there?

Any F# programmers out there?
I recently started studying computer science and I need to make a multiplication table like pic using 2 for-loops and I just cant get it to work.
I once got it to print a row from left to right from 1-10 and the same as a colum, but to fill out the rest was really a challenge.
Anyone who can help?

Other urls found in this thread:

msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/core.printf-module-[fsharp]
amazon.com/Functional-Programming-Using-Michael-Hansen/dp/1107684064
twitter.com/NSFWRedditVideo

One loop for the rows, one for the columns. Ezpz

Idk f# but here's some pseudocode:

For i=1 to 10
For j=1 to 10
Print i*j
End
Print newline
End

I tried something like that, but still can't get the last part to work with i*j.

If I try to add:
printf i*j

it says that i is not defined and errors out.

I dont know any f# and ive never heard of it but the solution will be

for i = 0 to 10 do
for j = 1 to 10 do
printf "%A " i*j
printf "\n"

>for i = 0 to 10 do
>for j = 1 to 10 do
>printf "%A " i*j
>printf "\n"
oh, Veeky Forums doesnt show indentation

for i = 0 to 10 do
___for j = 1 to 10 do
______printf "%A " i*j
___printf "\n"

Ok I tried running it with this code and i get this...

I don't know if I have to include a if/else/then statement to it somewhere for it to work properly. This "simple" task confuses me way more than it should I feel.

Forgot the code

printf "%d" for ints.

I dont know man seems like %A is the wrong data type

try this

for i = 0 to 10 do
___for j = 1 to 10 do
______printf "%d " i*j
___printf "\n"

info here
msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/core.printf-module-[fsharp]

Getting the same exact error. This is so annoying

aw man you gotta remember your parentheses around i*j.

Oh shit, now something happened!
A requirement is still to make the table look nice and alligned. Anyone got ideas to make this happen?

Well one way would be to use tab instead of " "

And you're still missing the
0 1 2 3..
1
2
3
lines

Curious what book you're using and where you're studying if you start with F# in imperative mode

Nvm I figured it out, had written down some notes on this apparently.

Wrote "%2d " instead of "%d " :)

or that yea

You're right, it still doesn't look exactly like the first pic, but close enough I think.

For the programming part or reading material is this book:
amazon.com/Functional-Programming-Using-Michael-Hansen/dp/1107684064

and notes our teacher wrote himself about f#, although I think they doesn't explain the stuff we have to solve well enough...I feel like I'm since I came in with no programming experience at all.
I have an assignment for wednesday, which I don't understand much of, it really sucks for me.

Studing computer science in Denmark, Copenhagen.
Apparently F# is something new they are trying out for the second year now

Same guy?

And don't worry about it if you feel you don't understand it. It can take a few months before you really get into the proper way of thinking.

As for assignments, it looks like you're on the right track, and even if it doesn't get approved in the first try as long as you make a good attempt it probably wont be a problem.

Just a heads up though. Your instructors browse Veeky Forums, stack exchange and reddit as well so keep the questions basic.

Yeah same guy.
I kind of figured they would as they aren't much older than myself. This multiplikation table isn't in the assignment though, just a practice task.

Was nice getting some different eyes looking at it

General advice though. Learn to understand what each error message and warning means.

Put parentheses around function calls as soon as they're not alone.

Ask your instructor for help or go upstairs and ask for help before going on the internet to gets help from random perverts.

Also, Veeky Forums is not for homework. /g/ has a daily programming thread where they'd be more than happy to help you and mock your code at all hours of the day.

literally newfriend, programming in Microsoft meme languages is not science