• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 03:10
CEST 09:10
KST 16:10
  • 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
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun12[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists22[ASL21] Ro16 Preview Pt1: Fresh Flow9
Community News
RSL Revival: Season 5 - Qualifiers and Main Event4Code S Season 1 (2026) - RO12 Results02026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced92026 GSL Tour plans announced15
StarCraft 2
General
Code S Season 1 (2026) - RO12 Results Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool MaNa leaves Team Liquid
Tourneys
RSL Revival: Season 5 - Qualifiers and Main Event GSL Code S Season 1 (2026) SC2 INu's Battles#15 <BO.9 2Matches> WardiTV Spring Cup SEL Masters #6 - Solar vs Classic (SC: Evo)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base Mutation # 521 Memorable Boss
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Pros React To: Leta vs Tulbo (ASL S21, Ro.8) [BSL22] RO16 Group A - Sunday 21:00 CEST [BSL22] RO16 Group B - Saturday 21:00 CEST RepMastered™: replay sharing and analyzer site
Tourneys
[BSL22] RO16 Group Stage - 02 - 10 May Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro8 Day 2
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Daigo vs Menard Best of 10 Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV Diablo IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1783 users

The Big Programming Thread - Page 552

Forum Index > General Forum
Post a Reply
Prev 1 550 551 552 553 554 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.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2014-11-28 09:46:37
November 28 2014 09:45 GMT
#11021
On November 28 2014 11:40 Manit0u wrote:
Show nested quote +
On November 28 2014 01:25 mostevil wrote:
On November 27 2014 20:44 Morfildur wrote:
On November 27 2014 18:57 Manit0u wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

Kinda sad...


I wouldn't give too much on that article. Apart from being fairly biased it's also extremely outdated with it's C# examples - which isn't surprising considering it's 8 years old and languages have developed a lot in that time.

The feeling of wanting feature X of language Y when you are developing Z is normal, no matter which language you use. All languages have a lot of features that other languages miss, because all languages specialize in different areas. While a specific feature might be useful, usually using the full language isn't, often due to missing libraries or other missing language features.

I do wish PHP had C# style lambda expressions and properties though


String.Join("\n", array.ConvertAll(x => x.Description).Where(x => x != '').ToArray());


I really need to start using lambdas at some point. Legacy OS' of my customers have me trapped at older versions of .NET. They still don't look natural to me yet, it's a weird ass syntax in a world that mostly looks like c.


I must say that I'm not a big fan of lambdas. Just like I'm not a big fan of chaining in PHP. It seems like trying to cram as much code as possible into one line which can make it less readable.

Don't get me wrong, I'm all for using anonymous functions and recursion when declaring "variables" but apart from that I think you start introducing too much clutter in imperative languages.


Lambdas are a complicated topic. While you are right to some degree and lambdas can add clutter to the code, well used lambdas can change the way you think about programming completely and make a lot of things easier to write and easier to read. C# Lambdas probably had the biggest impact on my programming thought process since the time I finally understood object oriented programming.

Cramming them into one line is simply a style problem and can be avoided with proper formatting.


users.Where(x => x.LastName == 'Doe')
.Where(x => x.Purchases.Any(p => p.Merchant == 'Amazon'))
.ToArray()
.ForEach(x => MailService.SendChristmasMail(x.ID));


vs


foreach (var user in users)
{
if (user.LastName == 'Doe')
{
bool hasAmazonPurchase = false;
foreach (var purchase in user.Purchases)
{
if (purchase.Merchant == 'Amazon')
{
hasAmazonPurchase = true;
break;
}
}

if (hasAmazonPurchase)
{
MailService.SendChristmasMail(user.ID);
}
}
}


Might be a contrived example, but I've had plenty of instances where the use of LINQ and Lambdas turned a 30 line method into a easy to read 1-3 line method. You can do the same by introducing more helper methods, but then again, those do what the first example already does, except they are specialized and less reusable.
Prillan
Profile Joined August 2011
Sweden350 Posts
November 28 2014 09:49 GMT
#11022
On November 28 2014 11:40 Manit0u wrote:
Show nested quote +
On November 28 2014 01:25 mostevil wrote:
On November 27 2014 20:44 Morfildur wrote:
On November 27 2014 18:57 Manit0u wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

Kinda sad...


I wouldn't give too much on that article. Apart from being fairly biased it's also extremely outdated with it's C# examples - which isn't surprising considering it's 8 years old and languages have developed a lot in that time.

The feeling of wanting feature X of language Y when you are developing Z is normal, no matter which language you use. All languages have a lot of features that other languages miss, because all languages specialize in different areas. While a specific feature might be useful, usually using the full language isn't, often due to missing libraries or other missing language features.

I do wish PHP had C# style lambda expressions and properties though


String.Join("\n", array.ConvertAll(x => x.Description).Where(x => x != '').ToArray());


I really need to start using lambdas at some point. Legacy OS' of my customers have me trapped at older versions of .NET. They still don't look natural to me yet, it's a weird ass syntax in a world that mostly looks like c.


I must say that I'm not a big fan of lambdas. Just like I'm not a big fan of chaining in PHP. It seems like trying to cram as much code as possible into one line which can make it less readable.

Don't get me wrong, I'm all for using anonymous functions and recursion when declaring "variables" but apart from that I think you start introducing too much clutter in imperative languages.

I get what you mean, but I like to do one "thing" per line.

The above C# code is a perfect example of this. I want to join the non-empty descriptions of the array, then it should be one line. I can understand the concept in one sentence so writing it in one line shouldn't be a problem.

Writing the equivalent code using a for-loop is what would clutter the code. Why should it take 6 lines?

var s = new StringBuilder();
foreach (var x in array)
{
if (x.Description != "")
s.AppendLine(x);
}
return s.ToString();
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Manit0u
Profile Blog Joined August 2004
Poland17741 Posts
Last Edited: 2014-11-28 11:08:58
November 28 2014 11:02 GMT
#11023
On November 28 2014 18:49 Prillan wrote:
Show nested quote +
On November 28 2014 11:40 Manit0u wrote:
On November 28 2014 01:25 mostevil wrote:
On November 27 2014 20:44 Morfildur wrote:
On November 27 2014 18:57 Manit0u wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

Kinda sad...


I wouldn't give too much on that article. Apart from being fairly biased it's also extremely outdated with it's C# examples - which isn't surprising considering it's 8 years old and languages have developed a lot in that time.

The feeling of wanting feature X of language Y when you are developing Z is normal, no matter which language you use. All languages have a lot of features that other languages miss, because all languages specialize in different areas. While a specific feature might be useful, usually using the full language isn't, often due to missing libraries or other missing language features.

I do wish PHP had C# style lambda expressions and properties though


String.Join("\n", array.ConvertAll(x => x.Description).Where(x => x != '').ToArray());


I really need to start using lambdas at some point. Legacy OS' of my customers have me trapped at older versions of .NET. They still don't look natural to me yet, it's a weird ass syntax in a world that mostly looks like c.


I must say that I'm not a big fan of lambdas. Just like I'm not a big fan of chaining in PHP. It seems like trying to cram as much code as possible into one line which can make it less readable.

Don't get me wrong, I'm all for using anonymous functions and recursion when declaring "variables" but apart from that I think you start introducing too much clutter in imperative languages.

I get what you mean, but I like to do one "thing" per line.

The above C# code is a perfect example of this. I want to join the non-empty descriptions of the array, then it should be one line. I can understand the concept in one sentence so writing it in one line shouldn't be a problem.

Writing the equivalent code using a for-loop is what would clutter the code. Why should it take 6 lines?

var s = new StringBuilder();
foreach (var x in array)
{
if (x.Description != "")
s.AppendLine(x);
}
return s.ToString();


Well, one could argue that breaking it into smaller parts like that gives you more leeway for when you need to refactor the code (as in, add additional guards or checks if necessary) since you can then put those extra bits in one place without having to change the rest.

Your example in PHP could look something like that:


function filterDescriptions($obj) {
$desc = isset($obj->description) ? $obj->description : "";

if ($desc !== "") {
return $desc;
}
}

$strArr = array_map("filterDescriptions", $objArr);
$str = implode("\n", $strArr);


The thing here is that you're really doing it with just 2 lines of code (which could be further reduced to 1) that immediately tell you what's going on. You have to look at the filterDescriptions method only when you really need to know how the filtering is done. And if you ever need to change the filtering method you just change the filter function and don't have to touch the rest of the code.

I find it more readable because each line of code does exactly one thing. You still have recursion in there, you just don't cram it all into a single line.

Another thing to note if you're concerned with app performance, lambdas and stuff like array.ConvertAll add quite a lot of overhead when compared to a simple foreach.
Time is precious. Waste it wisely.
Prillan
Profile Joined August 2011
Sweden350 Posts
November 28 2014 13:05 GMT
#11024
On November 28 2014 20:02 Manit0u wrote:
Show nested quote +
On November 28 2014 18:49 Prillan wrote:
On November 28 2014 11:40 Manit0u wrote:
On November 28 2014 01:25 mostevil wrote:
On November 27 2014 20:44 Morfildur wrote:
On November 27 2014 18:57 Manit0u wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

Kinda sad...


I wouldn't give too much on that article. Apart from being fairly biased it's also extremely outdated with it's C# examples - which isn't surprising considering it's 8 years old and languages have developed a lot in that time.

The feeling of wanting feature X of language Y when you are developing Z is normal, no matter which language you use. All languages have a lot of features that other languages miss, because all languages specialize in different areas. While a specific feature might be useful, usually using the full language isn't, often due to missing libraries or other missing language features.

I do wish PHP had C# style lambda expressions and properties though


String.Join("\n", array.ConvertAll(x => x.Description).Where(x => x != '').ToArray());


I really need to start using lambdas at some point. Legacy OS' of my customers have me trapped at older versions of .NET. They still don't look natural to me yet, it's a weird ass syntax in a world that mostly looks like c.


I must say that I'm not a big fan of lambdas. Just like I'm not a big fan of chaining in PHP. It seems like trying to cram as much code as possible into one line which can make it less readable.

Don't get me wrong, I'm all for using anonymous functions and recursion when declaring "variables" but apart from that I think you start introducing too much clutter in imperative languages.

I get what you mean, but I like to do one "thing" per line.

The above C# code is a perfect example of this. I want to join the non-empty descriptions of the array, then it should be one line. I can understand the concept in one sentence so writing it in one line shouldn't be a problem.

Writing the equivalent code using a for-loop is what would clutter the code. Why should it take 6 lines?

var s = new StringBuilder();
foreach (var x in array)
{
if (x.Description != "")
s.AppendLine(x);
}
return s.ToString();


Well, one could argue that breaking it into smaller parts like that gives you more leeway for when you need to refactor the code (as in, add additional guards or checks if necessary) since you can then put those extra bits in one place without having to change the rest.

Your example in PHP could look something like that:


function filterDescriptions($obj) {
$desc = isset($obj->description) ? $obj->description : "";

if ($desc !== "") {
return $desc;
}
}

$strArr = array_map("filterDescriptions", $objArr);
$str = implode("\n", $strArr);


The thing here is that you're really doing it with just 2 lines of code (which could be further reduced to 1) that immediately tell you what's going on. You have to look at the filterDescriptions method only when you really need to know how the filtering is done. And if you ever need to change the filtering method you just change the filter function and don't have to touch the rest of the code.

I find it more readable because each line of code does exactly one thing. You still have recursion in there, you just don't cram it all into a single line.

Another thing to note if you're concerned with app performance, lambdas and stuff like array.ConvertAll add quite a lot of overhead when compared to a simple foreach.

Does it though? It took me some time to realize what
$desc = isset($obj->description) ? $obj->description : "";
did. I could call that "doing more than one thing".

But I think that we are on the same page here. No one wants to have unreadable code that does too much in one step. I'm just a bit more tolerant to long lines

Also, from what I can see there is no recursion anywhere in either the C# one or your example. What do you mean?
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
November 28 2014 13:19 GMT
#11025
--- Nuked ---
Prillan
Profile Joined August 2011
Sweden350 Posts
Last Edited: 2014-11-28 13:39:29
November 28 2014 13:37 GMT
#11026
On November 28 2014 22:19 Nesserev wrote:
Show nested quote +
On November 28 2014 22:05 Prillan wrote:
On November 28 2014 20:02 Manit0u wrote:
On November 28 2014 18:49 Prillan wrote:
On November 28 2014 11:40 Manit0u wrote:
On November 28 2014 01:25 mostevil wrote:
On November 27 2014 20:44 Morfildur wrote:
On November 27 2014 18:57 Manit0u wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

Kinda sad...


I wouldn't give too much on that article. Apart from being fairly biased it's also extremely outdated with it's C# examples - which isn't surprising considering it's 8 years old and languages have developed a lot in that time.

The feeling of wanting feature X of language Y when you are developing Z is normal, no matter which language you use. All languages have a lot of features that other languages miss, because all languages specialize in different areas. While a specific feature might be useful, usually using the full language isn't, often due to missing libraries or other missing language features.

I do wish PHP had C# style lambda expressions and properties though


String.Join("\n", array.ConvertAll(x => x.Description).Where(x => x != '').ToArray());


I really need to start using lambdas at some point. Legacy OS' of my customers have me trapped at older versions of .NET. They still don't look natural to me yet, it's a weird ass syntax in a world that mostly looks like c.


I must say that I'm not a big fan of lambdas. Just like I'm not a big fan of chaining in PHP. It seems like trying to cram as much code as possible into one line which can make it less readable.

Don't get me wrong, I'm all for using anonymous functions and recursion when declaring "variables" but apart from that I think you start introducing too much clutter in imperative languages.

I get what you mean, but I like to do one "thing" per line.

The above C# code is a perfect example of this. I want to join the non-empty descriptions of the array, then it should be one line. I can understand the concept in one sentence so writing it in one line shouldn't be a problem.

Writing the equivalent code using a for-loop is what would clutter the code. Why should it take 6 lines?

var s = new StringBuilder();
foreach (var x in array)
{
if (x.Description != "")
s.AppendLine(x);
}
return s.ToString();


Well, one could argue that breaking it into smaller parts like that gives you more leeway for when you need to refactor the code (as in, add additional guards or checks if necessary) since you can then put those extra bits in one place without having to change the rest.

Your example in PHP could look something like that:


function filterDescriptions($obj) {
$desc = isset($obj->description) ? $obj->description : "";

if ($desc !== "") {
return $desc;
}
}

$strArr = array_map("filterDescriptions", $objArr);
$str = implode("\n", $strArr);


The thing here is that you're really doing it with just 2 lines of code (which could be further reduced to 1) that immediately tell you what's going on. You have to look at the filterDescriptions method only when you really need to know how the filtering is done. And if you ever need to change the filtering method you just change the filter function and don't have to touch the rest of the code.

I find it more readable because each line of code does exactly one thing. You still have recursion in there, you just don't cram it all into a single line.

Another thing to note if you're concerned with app performance, lambdas and stuff like array.ConvertAll add quite a lot of overhead when compared to a simple foreach.

Does it though? It took me some time to realize what
$desc = isset($obj->description) ? $obj->description : "";
did. I could call that "doing more than one thing".

But I think that we are on the same page here. No one wants to have unreadable code that does too much in one step. I'm just a bit more tolerant to long lines

Also, from what I can see there is no recursion anywhere in either the C# one or your example. What do you mean?

I'm pretty sure he's referring to 'array_map'.

'map'-functions apply a function to every element in a list/array, and this is normally implemented in a recursive way where the function is applied to the head of the list, and the function is "mapped" to the rest of the list. Hence, you can treat array_map as recursive.

I'm well aware of the regular "description" of map. I can't say anything about how it's implemented but I doubt that it's recursive, especially in an imperative language. If you still want to describe it as recursive, then you could call any abstract function recursive, because it could be implemented recursively.

Anyway, enough of that useless discussion. What I wanted to point out with my question was that there is a difference between "functional" and "recursive", and that just because something is imported from a functional language doesn't mean that it shouldn't be used in an imperative one.

Edit: I'm a bit tired right now so I'm sorry if I sound, I don't know, not nice...
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Manit0u
Profile Blog Joined August 2004
Poland17741 Posts
Last Edited: 2014-11-28 15:47:14
November 28 2014 15:10 GMT
#11027
On November 28 2014 22:37 Prillan wrote:
Show nested quote +
On November 28 2014 22:19 Nesserev wrote:
On November 28 2014 22:05 Prillan wrote:
On November 28 2014 20:02 Manit0u wrote:
On November 28 2014 18:49 Prillan wrote:
On November 28 2014 11:40 Manit0u wrote:
On November 28 2014 01:25 mostevil wrote:
On November 27 2014 20:44 Morfildur wrote:
On November 27 2014 18:57 Manit0u wrote:
http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

Kinda sad...


I wouldn't give too much on that article. Apart from being fairly biased it's also extremely outdated with it's C# examples - which isn't surprising considering it's 8 years old and languages have developed a lot in that time.

The feeling of wanting feature X of language Y when you are developing Z is normal, no matter which language you use. All languages have a lot of features that other languages miss, because all languages specialize in different areas. While a specific feature might be useful, usually using the full language isn't, often due to missing libraries or other missing language features.

I do wish PHP had C# style lambda expressions and properties though


String.Join("\n", array.ConvertAll(x => x.Description).Where(x => x != '').ToArray());


I really need to start using lambdas at some point. Legacy OS' of my customers have me trapped at older versions of .NET. They still don't look natural to me yet, it's a weird ass syntax in a world that mostly looks like c.


I must say that I'm not a big fan of lambdas. Just like I'm not a big fan of chaining in PHP. It seems like trying to cram as much code as possible into one line which can make it less readable.

Don't get me wrong, I'm all for using anonymous functions and recursion when declaring "variables" but apart from that I think you start introducing too much clutter in imperative languages.

I get what you mean, but I like to do one "thing" per line.

The above C# code is a perfect example of this. I want to join the non-empty descriptions of the array, then it should be one line. I can understand the concept in one sentence so writing it in one line shouldn't be a problem.

Writing the equivalent code using a for-loop is what would clutter the code. Why should it take 6 lines?

var s = new StringBuilder();
foreach (var x in array)
{
if (x.Description != "")
s.AppendLine(x);
}
return s.ToString();


Well, one could argue that breaking it into smaller parts like that gives you more leeway for when you need to refactor the code (as in, add additional guards or checks if necessary) since you can then put those extra bits in one place without having to change the rest.

Your example in PHP could look something like that:


function filterDescriptions($obj) {
$desc = isset($obj->description) ? $obj->description : "";

if ($desc !== "") {
return $desc;
}
}

$strArr = array_map("filterDescriptions", $objArr);
$str = implode("\n", $strArr);


The thing here is that you're really doing it with just 2 lines of code (which could be further reduced to 1) that immediately tell you what's going on. You have to look at the filterDescriptions method only when you really need to know how the filtering is done. And if you ever need to change the filtering method you just change the filter function and don't have to touch the rest of the code.

I find it more readable because each line of code does exactly one thing. You still have recursion in there, you just don't cram it all into a single line.

Another thing to note if you're concerned with app performance, lambdas and stuff like array.ConvertAll add quite a lot of overhead when compared to a simple foreach.

Does it though? It took me some time to realize what
$desc = isset($obj->description) ? $obj->description : "";
did. I could call that "doing more than one thing".

But I think that we are on the same page here. No one wants to have unreadable code that does too much in one step. I'm just a bit more tolerant to long lines

Also, from what I can see there is no recursion anywhere in either the C# one or your example. What do you mean?

I'm pretty sure he's referring to 'array_map'.

'map'-functions apply a function to every element in a list/array, and this is normally implemented in a recursive way where the function is applied to the head of the list, and the function is "mapped" to the rest of the list. Hence, you can treat array_map as recursive.

I'm well aware of the regular "description" of map. I can't say anything about how it's implemented but I doubt that it's recursive, especially in an imperative language. If you still want to describe it as recursive, then you could call any abstract function recursive, because it could be implemented recursively.

Anyway, enough of that useless discussion. What I wanted to point out with my question was that there is a difference between "functional" and "recursive", and that just because something is imported from a functional language doesn't mean that it shouldn't be used in an imperative one.

Edit: I'm a bit tired right now so I'm sorry if I sound, I don't know, not nice...


I believe everyone is confused by now

I confused you with my too long of a line of code that did more than one thing because my habits prevented me to simply assign a value from the object to a variable before previously checking if that value even exists with a ternary operator, which made the code confusing In all honesty, I should've first initialized variable to an empty string, then test if object has this attribute set and then make sure that it's assigned to the variable as a string and only then move on with the rest of the code. I would really like it if PHP wouldn't have this "smart" variables of mixed type everywhere...

Now a JavaScript question for you people. My brain does not want to function any more today...

I have a form with dropdown menus. It updates automatically whenever a new value is chosen from those dropdowns. The problem:

1. I select some values to filter the list of items. All cool and dandy.
2. I select one of those items, which brings me to its page.
3. I press 'back' button in the browser.

Now, FF brings me back to the filter select page, with filters selected and item list being filtered. WebKit browsers go back to this page, filters are selected but the list isn't filtered (reloading the page applies filters properly).

Edit: The funny thing is - after reloading the page in Chrome, selecting the product and going back everything works just fine like in FF.

Do you have any idea what could be causing that and how to fix it?
Time is precious. Waste it wisely.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
November 28 2014 15:55 GMT
#11028
--- Nuked ---
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 28 2014 18:25 GMT
#11029
I tend to declare descriptively named variables after each LINQ statement rather than chaining them across multiple lines. I also tend to replace lambdas with method groups by turning the lambda into a single-line method.

The big thing with LINQ is that it shifts attention towards list manipulation and away from looking at single items in a list and applying a series of operations on each single item.
If you have a good reason to disagree with the above, please tell me. Thank you.
Cynry
Profile Blog Joined August 2010
810 Posts
Last Edited: 2014-12-01 11:21:05
December 01 2014 11:16 GMT
#11030
Ok, so, I need help again, but good news, it's not a segfault this time ! I can usually take care of those now, yay me...

Anyway, recoding some of the ls command right now, and I'm having trouble with the -R option.
Here's what I have :
t_list          *ft_output_bigr(t_input *input)
{
t_list *dir_content;
DIR *dir_stream;
struct dirent *buf;

if (!input->files->content && !input->dir->content)
return (NULL);
if (input->files->content)
return (ft_lstcpy_and_del(input->files));
dir_stream = opendir(input->dir->content);
ft_lstfreeone(&input->dir, input->dir);
while ((buf = readdir(dir_stream)))
{
dir_content = ft_lstnew(buf->d_name, sizeof(buf->d_name));
ft_lstadd(&input->files, dir_content);
if ((ft_is_dir(buf->d_name)) && ft_strcmp(buf->d_name, ".") != 0
&& ft_strcmp(buf->d_name, "..") != 0)
{
ft_lstadd(&input->dir, dir_content);
}
}
closedir(dir_stream);
return (ft_lstcpy_and_del(input->files));
}

and the function that calls it :
int             ft_process_input(t_input **input)
{
t_list *output;

while ((output = (ft_strchr((*input)->opt, 'R')) ? ft_output_bigr(*input)
: ft_output(*input)))
{
output = (ft_strchr((*input)->opt, 'a')) ? output
: ft_rem_hidden(&output);
output = (ft_strchr((*input)->opt, 't')) ? ft_t(&output)
: ft_parse(&output);
output = (ft_strchr((*input)->opt, 'r')) ? ft_lstrev(&output) : output;
output = (ft_strchr((*input)->opt, 'l')) ? ft_l(output) : output;
while (output)
{
ft_putendl(output->content);
ft_lstfreeone(&output, output);
}
}
return (1);
}

The idea is to check for files in the list as they are handled first with ls, then open a directory from the dir list, add its content to the now cleared files list, and add the sub-directories in the dir list. Considering how list works, it seemed a better alternative to recursivity to handle the -R option.
It's pretty much the exact same code as how I get my output without options, and it works in that case. But for -R, all I get in my output is the list of directories, no files. The code shouldn't do that. Why is it doing that ? I've checked what is added in the files list when a directory is read, and there is everything. Then I return a copy of it, and it's all directories. Waddafuck ?

Edit : I know that right now the function wouldn't work anyway because directory name != pathname, but I don't think that is the issue...
The issue also seems to only appear when my ls is used without argument other than options. In which case what I do is create a node for the dir list containing ".". Again, it works without the -R option...
Isualin
Profile Joined March 2011
Germany1903 Posts
December 01 2014 11:34 GMT
#11031
Is anyone here using mongodb in production? Our db dumps are over 120gb and it has become a pretty long task to mongodump/zip/unzip/mongorestore. So i need to implement automatic incremental database backups on our server. I have found something named tayra. But i could use some help from someone with experience.
| INnoVation | The literal god TY | ByuNjwa | LRSL when? |
Khalum
Profile Joined September 2010
Austria831 Posts
Last Edited: 2014-12-01 11:54:41
December 01 2014 11:53 GMT
#11032
Is there any way I can trick the Notepad++ syntax highlighting to colour variables in a certain way?
I'd like "x=123" to work and would be even more happy if I could get it to work with variable space before and after the "=" (x should be coloured).

[edit] Yes I've checked http://udl20.weebly.com/ but that didn't help.
Animzor
Profile Joined March 2011
Sweden2154 Posts
Last Edited: 2014-12-01 14:49:57
December 01 2014 14:44 GMT
#11033
Got a simple homework question(Java):

I'm trying to set up a program where I can create users and contracts(and a bunch of other stuff, but this is what I'm stuck on). Every contract needs to have a number of users and each user tied to the contract owns a percentage of the contract. What I have so far is a contract class with an arraylist that takes users, but I am stuck trying to append a percentage to each one of them. Any tips?
LaNague
Profile Blog Joined April 2010
Germany9118 Posts
Last Edited: 2014-12-01 14:58:51
December 01 2014 14:56 GMT
#11034
you could just use a second array.


Im sure there are more clever java specific solutions where you can pair a pointer and a double that would look better, though.


You could for example make your own structure that holds a pointer to the user and a percentage value as double.
I think Java has no struct, so you would make it a class with public attributes maybe.
Animzor
Profile Joined March 2011
Sweden2154 Posts
December 01 2014 15:09 GMT
#11035
Thanks man, gonna try making it a class.
Khalum
Profile Joined September 2010
Austria831 Posts
December 01 2014 15:10 GMT
#11036
On December 01 2014 23:56 LaNague wrote:
you could just use a second array.


Im sure there are more clever java specific solutions where you can pair a pointer and a double that would look better, though.


You could for example make your own structure that holds a pointer to the user and a percentage value as double.
I think Java has no struct, so you would make it a class with public attributes maybe.


Holy shit.

1) Don't use a second array.
2) Java has no pointers.
3) Don't make the attributes public.
bangsholt
Profile Joined June 2011
Denmark138 Posts
December 01 2014 16:30 GMT
#11037
On December 01 2014 23:44 Animzor wrote:
Got a simple homework question(Java):

I'm trying to set up a program where I can create users and contracts(and a bunch of other stuff, but this is what I'm stuck on). Every contract needs to have a number of users and each user tied to the contract owns a percentage of the contract. What I have so far is a contract class with an arraylist that takes users, but I am stuck trying to append a percentage to each one of them. Any tips?


One way to model it, and correct me if I'm wrong in my assumptions, but to me it sounds like you have a many-to-many relationship between users and contracts?

So, what you could do, is as follows.

You make a new class, that has a User, a Contract and a Owner Percentage.

Then you can make an ArrayList of that class - and you've solved your exercise :-)
Cynry
Profile Blog Joined August 2010
810 Posts
December 01 2014 17:38 GMT
#11038
Fixed my issue, happens that you can't add a node to 2 lists and expect to have 2 separate lists as a result. Nope.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2014-12-01 18:43:20
December 01 2014 18:42 GMT
#11039
On December 02 2014 00:10 Khalum wrote:
Show nested quote +
On December 01 2014 23:56 LaNague wrote:
you could just use a second array.


Im sure there are more clever java specific solutions where you can pair a pointer and a double that would look better, though.


You could for example make your own structure that holds a pointer to the user and a percentage value as double.
I think Java has no struct, so you would make it a class with public attributes maybe.


Holy shit.

1) Don't use a second array.
2) Java has no pointers.
3) Don't make the attributes public.


To Khalum,
1) A second array is pretty close to how most Maps are implemented, so it would be a fine way to accomplish this.
2) Java will pass by reference if the parameter is an Object. That's close enough to a pointer that you can do everything you could normally with pointers except change the pointer itself.
3) Make your attributes global and static iff you care about performance. This is like a struct. Make them public or public static in singletons if you need to use the struct itself as an Object. Make them private otherwise.


To answer the specific question about how to pair a User Object with a double value, look up the Map interface in the API. The HashMap Class is a widely used implementation of that interface. It allows you to pair up Objects, such as Users and Doubles. Instead of having an ArrayList of Users for the Contract, you use a HashMap<User,Double> to store the data.
Any sufficiently advanced technology is indistinguishable from magic
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
December 01 2014 19:37 GMT
#11040
On December 02 2014 03:42 RoyGBiv_13 wrote:
1) A second array is pretty close to how most Maps are implemented, so it would be a fine way to accomplish this.

There is a massive difference between using 2 arrays and using something that is implemented using 2 arrays. An array-based implementation of maps also would perform badly at the things maps are used for, so I highly doubt that's how "most maps are implemented". I'd rather bet on some hashtable of pairs plus maybe a linked list for iteration over all elements in the map.
If you have a good reason to disagree with the above, please tell me. Thank you.
Prev 1 550 551 552 553 554 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 50m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech130
StarCraft: Brood War
PianO 747
firebathero 354
Shine 321
Aegong 99
Backho 79
scan(afreeca) 14
ZergMaN 12
JulyZerg 9
Zeus 1
Dota 2
NeuroSwarm204
League of Legends
JimRising 670
Counter-Strike
Stewie2K1454
Other Games
summit1g6694
WinterStarcraft666
C9.Mang0500
monkeys_forever347
Sick245
ToD43
Organizations
Other Games
gamesdonequick676
Dota 2
PGL Dota 2 - Main Stream96
StarCraft: Brood War
UltimateBattle 53
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 13 non-featured ]
StarCraft 2
• Sammyuel 33
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt553
• TFBlade533
Upcoming Events
Replay Cast
1h 50m
RSL Revival
2h 50m
Classic vs GgMaChine
Rogue vs Maru
WardiTV Invitational
3h 50m
Percival vs Shameless
ByuN vs YoungYakov
SC Evo League
6h 50m
IPSL
8h 50m
Ret vs Art_Of_Turtle
Radley vs TBD
BSL
11h 50m
Replay Cast
16h 50m
RSL Revival
1d 2h
herO vs TriGGeR
NightMare vs Solar
uThermal 2v2 Circuit
1d 6h
BSL
1d 11h
[ Show More ]
IPSL
1d 11h
eOnzErG vs TBD
G5 vs Nesh
Patches Events
1d 16h
Replay Cast
2 days
Wardi Open
2 days
Afreeca Starleague
2 days
Jaedong vs Light
Monday Night Weeklies
2 days
Replay Cast
2 days
Sparkling Tuna Cup
3 days
Afreeca Starleague
3 days
Snow vs Flash
WardiTV Invitational
3 days
GSL
4 days
Classic vs Cure
Maru vs Rogue
GSL
5 days
SHIN vs Zoun
ByuN vs herO
OSC
5 days
Replay Cast
5 days
Escore
6 days
The PondCast
6 days
WardiTV Invitational
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Escore Tournament S2: W5
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
KK 2v2 League Season 1
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 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.