Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Edgar_Herrera, VoroneTZ, Akow), 973 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 6 1 2 3 4 5 6
Re: What's (currently) your favourite snippet of code? [Re: fogman] #444593
08/14/14 20:06
08/14/14 20:06
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Originally Posted By: fogman
using System.Collections.Generic;

Someone just encountered the awesomeness of having a awesome standard library?

I have two snippets:

C#
Code:
list.RemoveAll((client) => !client.Update());



C/C++
Code:
void magicFunc(char *d, const char *s) {
    while(*d++ = *s++);
}



Visit my site: www.masterq32.de
Re: What's (currently) your favourite snippet of code? [Re: MasterQ32] #444600
08/14/14 22:25
08/14/14 22:25
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
String copy and functional programming.

I can +1 the functional programming with reactive functional programming. I know that C# can do it better, but oh well.

Code:
RAC(createButton, enabled) = [RACSignal 
    combineLatest:@[ RACObserve(self, password), RACObserve(self, passwordConfirmation) ] 
    reduce:^(NSString *password, NSString *passwordConfirm) {
        return @([passwordConfirm isEqualToString:password]);
    }];



Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: What's (currently) your favourite snippet of code? [Re: MasterQ32] #444601
08/14/14 22:26
08/14/14 22:26
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Java 7 allows switches on strings. O-m-f-g!

Code:
public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) {

    String typeOfDay;
    
    switch (dayOfWeekArg) {
    
        case "Monday":      typeOfDay = "Start of work week";
                            break;
    
        case "Tuesday":
        case "Wednesday":
        case "Thursday":    typeOfDay = "Midweek";
                            break;
    
        case "Friday":      typeOfDay = "End of work week";
                            break;
    
        case "Saturday":
        case "Sunday":      typeOfDay = "Weekend";
                            break;
    
        default:            throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg);
    }
    
    return typeOfDay;
}


Last edited by HeelX; 08/14/14 22:27.
Re: What's (currently) your favourite snippet of code? [Re: HeelX] #444604
08/14/14 22:45
08/14/14 22:45
Joined: Oct 2002
Posts: 806
Zapan@work Offline
User
Zapan@work  Offline
User

Joined: Oct 2002
Posts: 806
Code:
float Q_rsqrt( float number )
{
	long i;
	float x2, y;
	const float threehalfs = 1.5F;
 
	x2 = number * 0.5F;
	y  = number;
	i  = * ( long * ) &y;                       // evil floating point bit level hacking
	i  = 0x5f3759df - ( i >> 1 );               // what the fuck?
	y  = * ( float * ) &i;
	y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//      y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed
 
	return y;
}


Re: What's (currently) your favourite snippet of code? [Re: HeelX] #444605
08/14/14 22:50
08/14/14 22:50
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
@Sid: I just wondered that you know C# that good, but then i stopped wondering. Testing programming languages is a nice thing, but sometimes hard to get into
I for myself keep distance to Objective-C, so much parenthesis, @s and stuff tongue

@HeelX: And that's why C# is better. Could do it from day 0. tongue
No, just kidding, but i have a strong personal preference to C# over Java as i like the concepts built into the language (structs, function pointers / delegates and the standard library is really awesome)

Another snippet in Lua:
Code:
Object = { new = function (self)
  local o = {}
  setmetatable(o, self)
  self.__index = self
  return o
end }



EDIT: @Zapan@work:
One of the most awesome C hacks i've ever seen.


Visit my site: www.masterq32.de
Re: What's (currently) your favourite snippet of code? [Re: MasterQ32] #444613
08/15/14 07:24
08/15/14 07:24
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
Originally Posted By: MasterQ32
i have a strong personal preference to C# over Java


fuck java, seriously. Fuck it right up the fucking arse with a 100" big black dildo.

edit: a dildo with titanium thorns and coated in 1.000.000 scoville hot sauce. On fire.

Last edited by Michael_Schwarz; 08/15/14 07:30.

"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: What's (currently) your favourite snippet of code? [Re: Michael_Schwarz] #444616
08/15/14 08:01
08/15/14 08:01
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
+1


Visit my site: www.masterq32.de
Re: What's (currently) your favourite snippet of code? [Re: Michael_Schwarz] #444628
08/15/14 17:08
08/15/14 17:08
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: Michael_Schwarz
Originally Posted By: MasterQ32
i have a strong personal preference to C# over Java


fuck java, seriously. Fuck it right up the fucking arse with a 100" big black dildo.

edit: a dildo with titanium thorns and coated in 1.000.000 scoville hot sauce. On fire.
Can this scale up? And sideways? Nope? Meh.

Re: What's (currently) your favourite snippet of code? [Re: HeelX] #444629
08/15/14 17:36
08/15/14 17:36
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
That dildo can scale diagonally if you use it with the wrong angle


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: What's (currently) your favourite snippet of code? [Re: WretchedSid] #444631
08/15/14 19:19
08/15/14 19:19
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
my.pan = your.pan + random(360);

Page 3 of 6 1 2 3 4 5 6

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1