• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 03:09
CEST 09:09
KST 16:09
  • 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] Ro16 Preview: Rough Waters9[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244
Community News
Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism5Official StarCraft website teases new content ahead of BlizzCon?118Stellar Fest TWO the Moon (Dec 16-20)9Weekly Cups (August 24-30): Patches' balance mod takes over3New 3v3 BGH Ladder (and more) on ShieldBattery!46
StarCraft 2
General
Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism Nexon wins bid to develop StarCraft IP content, distribute Overwatch mobile game Balance hotfix patch 5.0.16b (July 16) SC4ALL: II Winner Will Earn a Spot at HSC 30! Weekly Cups (August 24-30): Patches' balance mod takes over
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) 2026 GSTL Announcement Sparkling Tuna Cup - Weekly Open Tournament Stellar Fest TWO the Moon (Dec 16-20) IntoTheTV X SOOP SC2 League : Weekly & Monthly
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 542 The Ascended Mutation # 541 Binary Choice The PondCast: SC2 News & Results Mutation # 540 Dodge This
Brood War
General
Official StarCraft website teases new content ahead of BlizzCon? [ASL22] Ro16 Preview: Rough Waters ASL22 General Discussion Pros React To: Calm's Big Brain Play Vs Mini New 3v3 BGH Ladder (and more) on ShieldBattery!
Tourneys
[ASL22] Ro16 Group B [Megathread] Daily Proleagues 2v2v2v2 Tournament [ASL22] Ro16 Group A
Strategy
Replay Review Process - What do you do? Simple Questions, Simple Answers Odyssey Mineral Stack Saturation Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread EVE Corporation Diablo IV [Maplestory Hardcore] Let's Play~!! General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread Trading/Investing Thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread
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
The Automated Ban List Northern Ireland Global Starcraft
Blogs
F* the Children and Get Off …
TrAiDoS
Dreaming of BW patches (mod…
c3rberUs
Regacy Esports: The Bh…
regacyesports
LOCKPICKING NOOB
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 5983 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
28102 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
Poland5861 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
Poland5861 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
3175 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
Poland5861 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
Next event in 3h 51m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
EnDerr 10
StarCraft: Brood War
Shuttle 5249
Rain 1604
BeSt 260
Leta 181
sSak 80
Hm[arnc] 51
Yoon 35
Mind 34
Bale 22
ZergMaN 16
[ Show more ]
Noble 9
Icarus 6
Dota 2
monkeys_forever307
League of Legends
JimRising 760
Super Smash Bros
hungrybox394
Other Games
WinterStarcraft490
ceh9400
Happy231
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH301
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• Light_VIP 8
• iopq 5
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota21375
• lizZardDota2122
League of Legends
• Lourlo1766
• Stunt330
Upcoming Events
Kung Fu Cup
3h 51m
Replay Cast
16h 51m
The PondCast
1d 2h
KCM Race Survival
1d 2h
Escore
2 days
IntoTheTV X SOOP
2 days
CranKy Ducklings
3 days
Sparkling Tuna Cup
4 days
Shopify Rebellion Sundays
4 days
Spirit vs Mixu
Clem vs TBD
RSL Revival
4 days
[ Show More ]
BlizzCon
4 days
Replay Cast
4 days
Afreeca Starleague
5 days
WardiTV Weekly
5 days
Afreeca Starleague
6 days
GSL
6 days
PiGosaur Cup
6 days
Liquipedia Results

Completed

Proleague 2026-09-08
PiG Sty Festival 8.0
Big Dog Cup 2026 Div 1

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL 2026 AUTUMN (S22)
Acropolis #5
Acropolis #5 - TRS
RSL Revival: Season 6
Calamity Invitational
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026

Upcoming

Escore Tournament S3: King of Kings
Acropolis #5 - GSA
Blizzard Classic Cup 2026
Acropolis #5 - GSB
Acropolis #5 - GSC
SC4ALL II: Brood War
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Blizzard Classic Cup 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
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
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.