Gamestudio Links
Zorro Links
Newest Posts
Increasing Number Animation
by gamers. 02/19/20 07:16
Behaviour of user-defined bars
by JamesHH. 02/18/20 18:41
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
9 registered members (Juanjo, AndrewAMD, 3run, gamers, txesmi, Sinuhet, Frederick_Lim, kalmar, Michael_Schwarz), 1,143 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
DebraSteed, Ricard, Apollo1, ziphnor, thomasprv
18377 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,750
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,750
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,438
Red Dwarf
Michael_Schwarz Online
Senior Expert
Michael_Schwarz  Online
Senior Expert

Joined: Aug 2003
Posts: 7,438
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,750
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,750
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,858
F
Firoball Offline
Senior Expert
Firoball  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,858
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