[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Any F# programmers out there? I recently started studying computer

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 21
Thread images: 6

File: multiplicationtable.png (2KB, 164x106px) Image search: [Google]
multiplicationtable.png
2KB, 164x106px
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?
>>
>>8371497
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
>>
File: fuck.png (16KB, 448x239px) Image search: [Google]
fuck.png
16KB, 448x239px
>>8371509
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.
>>
>>8371518
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"
>>
>>8371540
>for i = 0 to 10 do
>for j = 1 to 10 do
>printf "%A " i*j
>printf "\n"
oh, 4chan doesnt show indentation

for i = 0 to 10 do
___for j = 1 to 10 do
______printf "%A " i*j
___printf "\n"
>>
File: scrnsht2.png (18KB, 832x447px) Image search: [Google]
scrnsht2.png
18KB, 832x447px
>>8371543
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.
>>
File: code1.png (10KB, 270x90px) Image search: [Google]
code1.png
10KB, 270x90px
>>8371543
>>8371572
Forgot the code
>>
>>8371572

printf "%d" for ints.
>>
>>8371577
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
https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/core.printf-module-%5Bfsharp%5D
>>
>>8371585
>>8371582
Getting the same exact error. This is so annoying
>>
>>8371595

aw man you gotta remember your parentheses around i*j.
>>
File: shot1.png (24KB, 585x235px) Image search: [Google]
shot1.png
24KB, 585x235px
>>8371598
Oh shit, now something happened!
A requirement is still to make the table look nice and alligned. Anyone got ideas to make this happen?
>>
>>8371608

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
>>
File: shot2.png (9KB, 280x227px) Image search: [Google]
shot2.png
9KB, 280x227px
>>8371608
Nvm I figured it out, had written down some notes on this apparently.

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

or that yea
>>
>>8371614
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:
https://www.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.
>>
>>8371614
Studing computer science in Denmark, Copenhagen.
Apparently F# is something new they are trying out for the second year now
>>
>>8371620
>>8371621

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 4chan, stack exchange and reddit as well so keep the questions basic.
>>
>>8371628
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
>>
>>8371636

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, /sci/ 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 >>>/g/ newfriend, programming in Microsoft meme languages is not science
Thread posts: 21
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.