• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:21
CET 20:21
KST 04:21
  • 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
[ASL22] Finals Preview: Sweet Victory!9[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Evil Geniuses - shutting down15ISSL (IntoTheTV x SOOP SC2 League): Premier5Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League77Weekly Cups (October 5-11): Farewell to 5.0.167
StarCraft 2
General
REPORT: StarCraft 2: Remastered In Development Evil Geniuses - shutting down How do you feel about the mass reverts in the 5.0.17 PTR? Team Liquid Map Contest #22: Results and Winners No more SC2 streamers on team liquid?
Tourneys
ScienceCraft (October 24-25) - Live Event Sparkling Tuna Cup - Weekly Open Tournament RSL goes to London! 2026 Offline Finals Nov 21-22 ISSL (IntoTheTV x SOOP SC2 League): Premier WORTEX Challenger Series — Open SC2 LAN in Budapes
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps [A] Nemrods 1/4 players [M] (2) Sweltering Sands
External Content
Mutation # 549 Endless Sparkles The PondCast: SC2 News & Results Mutation # 548 Shining Bright Mutation # 547 Temple Of Terror
Brood War
General
Recent recommended BW games [Megathread] Daily Funny Videos Hands of Pluto Oceanic Brood War - Join and chat! Bot on ladder
Tourneys
[Megathread] Daily Proleagues [$1250] International ShieldBattery League [ASL22] Grand Finals [BSL23] RO24 Group C
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Mobile Legends: Bang Bang Armies of Exigo - YesYes? General RTS Discussion Thread
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread European Politico-economics QA Mega-thread Canadian Politics Mega-thread
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 12202 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
28104 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
Poland5891 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
Poland5891 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
3176 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
Poland5891 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
Poland4769 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
IntoTheTV X SOOP
02:00
Group C Replay Cast
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 344
JuggernautJason77
BRAT_OK 64
EmSc Tv 22
MindelVK 12
StarCraft: Brood War
Britney 20027
Shuttle 353
Dewaltoss 146
firebathero 136
White-Ra 108
Zeus 53
ProTech46
910 26
HiyA 17
Sacsri 10
League of Legends
Trikslyr46
Counter-Strike
pashabiceps1224
Heroes of the Storm
Liquid`Hasu502
Other Games
Grubby4011
FrodaN1070
shahzam390
B2W.Neo345
C9.Mang0122
KnowMe94
QueenE57
Organizations
Counter-Strike
PGL62270
Other Games
WardiTV191
StarCraft 2
EmSc Tv 22
EmSc2Tv 22
[ Show 18 non-featured ]
StarCraft 2
• Adnapsc2 12
• Reevou 6
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• HerbMon 42
• FirePhoenix20
• Pr0nogo 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis3083
• TFBlade578
Other Games
• imaqtpie900
• Shiphtur675
• WagamamaTV41
Upcoming Events
PiGosaur Cup
5h 9m
IntoTheTV X SOOP
6h 39m
TaKeTV 367
The PondCast
14h 39m
Kung Fu Cup
15h 39m
IntoTheTV X SOOP
1d 15h
SHIN vs GuMiho
Clem vs Classic
OSC
2 days
WardiTV Invitational
2 days
GSL
2 days
Epic.LAN
2 days
Replay Cast
3 days
[ Show More ]
Sparkling Tuna Cup
3 days
Epic.LAN
3 days
Yamato Cup
4 days
Map Test Tournament
5 days
WardiTV Weekly
5 days
Replay Cast
6 days
Rogue vs Classic
Patches Events
6 days
Liquipedia Results

Completed

Acropolis #5 - GSC
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

IPSL Winter 2026-27
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
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.