• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 03:23
CET 09:23
KST 17:23
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Behind the Blue - Team Liquid History Book15Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8herO wins SC2 All-Star Invitational14
Community News
ACS replaced by "ASL Season Open" - Starts 21/0218LiuLi Cup: 2025 Grand Finals (Feb 10-16)23Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2Nexon's StarCraft game could be FPS, led by UMS maker10PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)13
StarCraft 2
General
How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Nexon's StarCraft game could be FPS, led by UMS maker Terran Scanner Sweep Behind the Blue - Team Liquid History Book Weekly Cups (Jan 12-18): herO, MaxPax, Solar win
Tourneys
RSL Season 4 announced for March-April LiuLi Cup: 2025 Grand Finals (Feb 10-16) PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) RSL Revival: Season 4 Korea Qualifier (Feb 14) Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ? [A] Starcraft Sound Mod
External Content
The PondCast: SC2 News & Results Mutation # 512 Overclocked Mutation # 511 Temple of Rebirth Mutation # 510 Safety Violation
Brood War
General
[ASL21] Potential Map Candidates Gypsy to Korea Which units you wish saw more use in the game? ACS replaced by "ASL Season Open" - Starts 21/02 Liquipedia.net NEEDS editors for Brood War
Tourneys
Escore Tournament StarCraft Season 1 [Megathread] Daily Proleagues Small VOD Thread 2.0 KCM Race Survival 2026 Season 1
Strategy
Fighting Spirit mining rates Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta
Other Games
General Games
Path of Exile Diablo 2 thread Nintendo Switch Thread Battle Aces/David Kim RTS Megathread ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Ask and answer stupid questions here! European Politico-economics QA Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
ADHD And Gaming Addiction…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2228 users

The Big Programming Thread - Page 835

Forum Index > General Forum
Post a Reply
Prev 1 833 834 835 836 837 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Askelad
Profile Joined October 2016
France20 Posts
Last Edited: 2017-02-18 17:49:28
February 05 2017 03:58 GMT
#16681
.
TheEmulator
Profile Blog Joined July 2010
28097 Posts
February 05 2017 04:30 GMT
#16682
Yea Matlab isn't too difficult to understand. I'm sure there's shitloads of materials on the internet to learn from as well. I never had to use it in Linear Algebra, although I used it a bit in Econometrics and I'm pretty sure we learned most of what was needed after a couple of tutorial lectures.
Administrator
maybenexttime
Profile Blog Joined November 2006
Poland5753 Posts
February 05 2017 08:19 GMT
#16683
MATLAB question.

I am learning how to create a simple dialog box GUI in Matlab, and I am not sure what is the proper way to handle invalid inputs. Namely, the pattern repeats itself: I have the parameter name, default value variable name, condition, and the error message.

Should I create a function that uses this pattern or leave it as it is now? Is it more proper to have explicit if statements or to reduce the number of lines considerably by making the if statements implicit (hidden in a dedicated function).

+ Show Spoiler +
while open_prompt
open_prompt = false;

answer_initial = inputdlg(prompt_initial, name_initial, num_lines, ...
default_initial);
default_initial{1} = answer_initial{1};

if (str2double(answer_initial{2}) >= 0) & ...
(str2double(answer_initial{2}) <= str2double(answer_initial{1}))

default_initial{2} = answer_initial{2};
else
uiwait(errordlg('Support A location outside of the beam length'));
default_initial{2} = '';
open_prompt = true;
end

if (str2double(answer_initial{3}) >= 0) & ...
(str2double(answer_initial{3}) <= str2double(answer_initial{1}))

default_initial{3} = answer_initial{3};
else
uiwait(errordlg('Support B location outside of the beam length'));
default_initial{3} = '';
open_prompt = true;
end

if (str2double(answer_initial{4}) >= 0)

default_initial{4} = answer_initial{4};
else
uiwait(errordlg('Number of distributed loads cannot be negative'));
default_initial{4} = '';
open_prompt = true;
end

if (str2double(answer_initial{5}) >= 0)

default_initial{5} = answer_initial{5};
else
uiwait(errordlg('Number of point loads cannot be negative'));
default_initial{5} = '';
open_prompt = true;
end

if (str2double(answer_initial{6}) >= 0)

default_initial{6} = answer_initial{6};
else
uiwait(errordlg('Number of point moments cannot be negative'));
default_initial{6} = '';
open_prompt = true;
end
end
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2017-02-05 08:53:27
February 05 2017 08:38 GMT
#16684
IMO this would be a better pattern


while loop

loop = false
data = get_input

if !cond
show_error
loop = true

if !cond
show_error
loop = true

...

if !loop
action


In which case no need to make a function
There is no one like you in the universe.
maybenexttime
Profile Blog Joined November 2006
Poland5753 Posts
February 05 2017 09:54 GMT
#16685
On February 05 2017 17:38 Blisse wrote:
IMO this would be a better pattern


while loop

loop = false
data = get_input

if !cond
show_error
loop = true

if !cond
show_error
loop = true

...

if !loop
action


In which case no need to make a function


Thanks for your input. I am, however, not sure this is going to maintain the same functionality. In my code the dialog box has a set of default values: default_initial = {'10', '0', '10', '1', '1', '1'}. By checking the validity of each input value individually, I can either replace the default value with the valid input value (default_initial{2} = answer_initial{2}) or make the field empty (default_initial{2} = '').

    if (str2double(answer_initial{2}) >= 0) & ...
(str2double(answer_initial{2}) <= str2double(answer_initial{1}))

default_initial{2} = answer_initial{2};
else
uiwait(errordlg('Support A location outside of the beam length'));
default_initial{2} = '';
open_prompt = true;
end


If I were to put all actions in the very last if statement, then upon opening the dialog box again (in the next iteration of the while loop) the initial default values would be used, and all valid inputs would be lost.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2017-02-05 13:17:25
February 05 2017 13:15 GMT
#16686
On February 05 2017 12:58 Askelad wrote:
Show nested quote +
On February 05 2017 10:14 Shield wrote:
On February 05 2017 10:05 slmw wrote:
But they're all equally correct in this case?! Tofucake's answer makes no sense.


No, they're not. It also depends if you should have one selection only. In that case, you cannot select more than one of them. However, even if you can, real numbers is more correct because it includes irrational numbers. I think irrational numbers still satisfy requirement in that question.

Real numbers = natural numbers + integers + rational numbers + irrational numbers.

Edit: It's a tricky question because you might not think of irrational numbers at all.


Makes even less sense. Seriously what was that rant about the irrationals...


Educate yourself: https://en.wikipedia.org/wiki/Irrational_number

On February 05 2017 12:17 travis wrote:
since it (understandably) turned into a semantics argument, I'll let everyone know that I selected all of the options and got the answer correct.


It doesn't seem the best answer to me. Real numbers should be better because others do not mention irrational numbers. Or did you select real numbers too?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
February 05 2017 13:57 GMT
#16687
--- Nuked ---
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2017-02-05 14:24:03
February 05 2017 14:04 GMT
#16688
On February 05 2017 22:57 Nesserev wrote:
Show nested quote +
On February 05 2017 22:15 Shield wrote:
On February 05 2017 12:58 Askelad wrote:
On February 05 2017 10:14 Shield wrote:
On February 05 2017 10:05 slmw wrote:
But they're all equally correct in this case?! Tofucake's answer makes no sense.


No, they're not. It also depends if you should have one selection only. In that case, you cannot select more than one of them. However, even if you can, real numbers is more correct because it includes irrational numbers. I think irrational numbers still satisfy requirement in that question.

Real numbers = natural numbers + integers + rational numbers + irrational numbers.

Edit: It's a tricky question because you might not think of irrational numbers at all.


Makes even less sense. Seriously what was that rant about the irrationals...


Educate yourself: https://en.wikipedia.org/wiki/Irrational_number

On February 05 2017 12:17 travis wrote:
since it (understandably) turned into a semantics argument, I'll let everyone know that I selected all of the options and got the answer correct.


It doesn't seem the best answer to me. Real numbers should be better because others do not mention irrational numbers. Or did you select real numbers too?

Uh, lol what? That's kind of uncalled for, especially because it's clear that you're in the wrong here. Sorry, but the one that needs a lesson is you... a lesson in not being an idiot, and perhaps set theory.

You should focus on this: "for all x in D[there exists a y in D ( x < y)]"

That statement is true for any number set Travis listed. If D is either the set of integers, natural numbers or rational numbers, there's zero reason to consider irrational numbers, because irrational numbers aren't in those sets...

How can 'true' be more correct than 'true'?

So, where is your confusion coming from? All that I can think of is that you didn't parse the question correctly, and think D is supposed to be any random interval of real numbers? And you seem to be reinforcing this idea because you're grasping back at irrational numbers...


Dude, you're wrong and you need to be taught how not to be an idiot. Or go study some math?

Integers: true (for all x in D[there exists a y in D ( x < y)])
Rational numbers: true (for all x in D[there exists a y in D ( x < y)])
Natural numbers: true (for all x in D[there exists a y in D ( x < y)])

Set of real numbers has integers, rational numbers and natural numbers. So, all of above is true. Plus, irrational numbers which are in the set of real numbers. E.g.
x = √2
y = √3
x < y


The set of real numbers is BIGGER than the union of natural numbers, integers and rationals.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2017-02-05 15:00:47
February 05 2017 14:59 GMT
#16689
For the record: The question asks for which set a condition holds, not which set among the list is the best match or anything like that. So you have to evaluate each set by itself. As per the wording of the question, the answer is "it is true for all 4 sets".
If you have a good reason to disagree with the above, please tell me. Thank you.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2017-02-05 15:04:11
February 05 2017 15:02 GMT
#16690
On February 05 2017 23:59 spinesheath wrote:
For the record: The question asks for which set a condition holds, not which set among the list is the best match or anything like that. So you have to evaluate each set by itself. As per the wording of the question, the answer is "it is true for all 4 sets". Nobody is doubting that integers are part of the real numbers, it just has nothing to do with the question.


Sure, I was asking travis if he chose all 4 but some people can't argue in a respectful way.

On February 05 2017 12:58 Askelad wrote:
Show nested quote +
On February 05 2017 10:14 Shield wrote:
On February 05 2017 10:05 slmw wrote:
But they're all equally correct in this case?! Tofucake's answer makes no sense.


No, they're not. It also depends if you should have one selection only. In that case, you cannot select more than one of them. However, even if you can, real numbers is more correct because it includes irrational numbers. I think irrational numbers still satisfy requirement in that question.

Real numbers = natural numbers + integers + rational numbers + irrational numbers.

Edit: It's a tricky question because you might not think of irrational numbers at all.


Makes even less sense. Seriously what was that rant about the irrationals...

Hanh
Profile Joined June 2016
146 Posts
February 05 2017 15:04 GMT
#16691
The question is not about which set include more numbers that fulfill the condition but which ones do or not. This isn't answering the question (and arguably showing off).
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-02-05 15:37:55
February 05 2017 15:36 GMT
#16692
I encrypted my vim file

how do I remove the encryption from within vim

I don't want it to be encrypted anymore

ok I figured it out

:set key=

vim is weird though.. I had to exit with :wq and not :x or it wasn't saving the change.. no idea why. wtf tbh
Wrath
Profile Blog Joined July 2014
3174 Posts
February 05 2017 15:47 GMT
#16693
On February 06 2017 00:36 travis wrote:
I encrypted my vim file

how do I remove the encryption from within vim

I don't want it to be encrypted anymore

ok I figured it out

:set key=

vim is weird though.. I had to exit with :wq and not :x or it wasn't saving the change.. no idea why. wtf tbh


Wasn't always :wq to save and :q! to exit without saving? Never heard of :x before.
Hanh
Profile Joined June 2016
146 Posts
February 05 2017 16:29 GMT
#16694
:x won't save if there are no changes. Maybe removing encryption isn't considered a change? Vim is weird.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-02-05 21:17:28
February 05 2017 20:32 GMT
#16695
WHAT IS GOING ON

why does this:


if(shape_choice == 2) {
scanf("%c ", &char_choice);
printf("%c", char_choice);
printf("Enter character and size: ");


simply print an empty line and then ask me for a character and size
it doesn't even give me a chance to input a character the first time

whelp, figured it out
any time you have a scanf you're gonna need a whitespace before your next scanf? that's so annoying
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2017-02-05 21:53:44
February 05 2017 21:52 GMT
#16696
Welcome to C where you can f*ck yourself nicely. Not that C++ is perfect, but it's much safer.

You might want to read this answer because your whitespace should be first: http://stackoverflow.com/a/13543113
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2017-02-05 23:17:35
February 05 2017 22:56 GMT
#16697
On February 05 2017 18:54 maybenexttime wrote:
Show nested quote +
On February 05 2017 17:38 Blisse wrote:
IMO this would be a better pattern


while loop

loop = false
data = get_input

if !cond
show_error
loop = true

if !cond
show_error
loop = true

...

if !loop
action


In which case no need to make a function


Thanks for your input. I am, however, not sure this is going to maintain the same functionality. In my code the dialog box has a set of default values: default_initial = {'10', '0', '10', '1', '1', '1'}. By checking the validity of each input value individually, I can either replace the default value with the valid input value (default_initial{2} = answer_initial{2}) or make the field empty (default_initial{2} = '').

    if (str2double(answer_initial{2}) >= 0) & ...
(str2double(answer_initial{2}) <= str2double(answer_initial{1}))

default_initial{2} = answer_initial{2};
else
uiwait(errordlg('Support A location outside of the beam length'));
default_initial{2} = '';
open_prompt = true;
end


If I were to put all actions in the very last if statement, then upon opening the dialog box again (in the next iteration of the while loop) the initial default values would be used, and all valid inputs would be lost.


Not totally certain I'm walking through your logic and explanation in the same way, but there is no next iteration of the loop if you've put all the action in the else block - the loop exits.

The `action` in my example would be doing whatever you needed with the answer_initial (in this case copying each value to default_initial).

edit: ohh okay I see what you mean by losing all the valid values on the next iteration, when the user enters valid and invalid values you want to keep the valid values and not set the invalid ones. Let me think about that..

edit2: i think your way is fine if you have that requirement. in that case i think it'd be nice to make a function. generally i disagree with making extra functions "for readability" if that function is only used once. the exception would be in cases where you'd expect that function to exist, i.e. client::isConnected(). in this case i'd like a somewhat generic function like `bool setArrayValueIfTrue(arr, index, value, cond)`.
There is no one like you in the universe.
maybenexttime
Profile Blog Joined November 2006
Poland5753 Posts
February 06 2017 09:18 GMT
#16698
On February 06 2017 07:56 Blisse wrote:
+ Show Spoiler +
On February 05 2017 18:54 maybenexttime wrote:
Show nested quote +
On February 05 2017 17:38 Blisse wrote:
IMO this would be a better pattern


while loop

loop = false
data = get_input

if !cond
show_error
loop = true

if !cond
show_error
loop = true

...

if !loop
action


In which case no need to make a function


Thanks for your input. I am, however, not sure this is going to maintain the same functionality. In my code the dialog box has a set of default values: default_initial = {'10', '0', '10', '1', '1', '1'}. By checking the validity of each input value individually, I can either replace the default value with the valid input value (default_initial{2} = answer_initial{2}) or make the field empty (default_initial{2} = '').

    if (str2double(answer_initial{2}) >= 0) & ...
(str2double(answer_initial{2}) <= str2double(answer_initial{1}))

default_initial{2} = answer_initial{2};
else
uiwait(errordlg('Support A location outside of the beam length'));
default_initial{2} = '';
open_prompt = true;
end


If I were to put all actions in the very last if statement, then upon opening the dialog box again (in the next iteration of the while loop) the initial default values would be used, and all valid inputs would be lost.


Not totally certain I'm walking through your logic and explanation in the same way, but there is no next iteration of the loop if you've put all the action in the else block - the loop exits.

The `action` in my example would be doing whatever you needed with the answer_initial (in this case copying each value to default_initial).

edit: ohh okay I see what you mean by losing all the valid values on the next iteration, when the user enters valid and invalid values you want to keep the valid values and not set the invalid ones. Let me think about that..

edit2: i think your way is fine if you have that requirement. in that case i think it'd be nice to make a function. generally i disagree with making extra functions "for readability" if that function is only used once. the exception would be in cases where you'd expect that function to exist, i.e. client::isConnected(). in this case i'd like a somewhat generic function like `bool setArrayValueIfTrue(arr, index, value, cond)`.


Thank you! I might have a few more questions regarding putting such recurring patterns into functions, but I'll give it a try myself first.
Silvanel
Profile Blog Joined March 2003
Poland4742 Posts
February 06 2017 09:31 GMT
#16699
So our customer just recently acccepted the software. Its a great feeling that work You (and few hundred other people) have been doing for last year and a half did not go in vain. Will be deployed to market in next 1-2 months.

I know this post isnt very productive. I just wanted to share my excitement.
Pathetic Greta hater.
AKnopf
Profile Blog Joined March 2011
Germany259 Posts
February 06 2017 09:45 GMT
#16700
On February 06 2017 18:31 Silvanel wrote:
So our customer just recently acccepted the software. Its a great feeling that work You (and few hundred other people) have been doing for last year and a half did not go in vain. Will be deployed to market in next 1-2 months.

I know this post isnt very productive. I just wanted to share my excitement.


Sharing positive feelings should never be considered unproductive. :-)

Congrats! It's always such a nice feeling to have your work published, even if it's only a small fix or a simple feature the customer needs. A satisfied customer is almost as good as the feeling when jenkins works and your latest commit doesn't break the test suite. ;-D
The world - its a funny place
Prev 1 833 834 835 836 837 1032 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
08:00
S4 Korea Server Qualifier
CranKy Ducklings78
Gemini_1927
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 158
ProTech48
Rex 34
StarCraft: Brood War
Hyuk 1680
Leta 88
Aegong 65
Free 39
Yoon 34
soO 19
910 18
IntoTheRainbow 15
Hm[arnc] 10
ivOry 8
[ Show more ]
Shine 8
League of Legends
JimRising 626
Super Smash Bros
Mew2King131
Other Games
gofns24656
summit1g11097
tarik_tv9806
C9.Mang0404
Organizations
Counter-Strike
PGL3378
Other Games
gamesdonequick586
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Adnapsc2 10
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1024
Upcoming Events
LiuLi Cup
2h 37m
Cure vs Reynor
Clem vs Maru
Rogue vs TriGGeR
ByuN vs Serral
uThermal 2v2 Circuit
3h 37m
PSISTORM Gaming Misc
8h 32m
RSL Revival
9h 37m
AI Arena Tournament
11h 37m
Replay Cast
15h 37m
Sparkling Tuna Cup
1d 1h
LiuLi Cup
1d 2h
Ladder Legends
1d 9h
Replay Cast
1d 15h
[ Show More ]
Replay Cast
2 days
Wardi Open
2 days
Monday Night Weeklies
2 days
OSC
2 days
WardiTV Winter Champion…
3 days
Replay Cast
4 days
WardiTV Winter Champion…
4 days
Replay Cast
4 days
PiG Sty Festival
5 days
The PondCast
5 days
KCM Race Survival
5 days
WardiTV Winter Champion…
5 days
Replay Cast
5 days
PiG Sty Festival
6 days
Epic.LAN
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Escore Tournament S1: W8
Rongyi Cup S3
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
LiuLi Cup: 2025 Grand Finals
Nations Cup 2026
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025

Upcoming

Escore Tournament S1: King of Kings
[S:21] ASL SEASON OPEN 1st Round
[S:21] ASL SEASON OPEN 1st Round Qualifier
[S:21] ASL SEASON OPEN 2nd Round
[S:21] ASL SEASON OPEN 2nd Round Qualifier
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
WardiTV Winter 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.