Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Post code

Name: Anonymous 2011-10-06 9:06

Any code you work with right now, and we'll criticize it(or not).

Name: HAXUS THE SAGE 2011-10-07 0:28

Not /prog/ related. GTFO!

Name: Anonymous 2011-10-07 0:52


sub addr-parse( Str $str, :$cidr ) {
    my @chunks = $str.comb: /\d+/;
    my $mask = @chunks[4] // 0;
    my $base = [+] @chunks[^4] Z+< 24, 16, 8, 0;
   
    return ( $base, $mask ) if $cidr;
    return $base;
}

sub cidr-str( Int $base, Int $mask ) {
    my $str = (
        for 24, 16, 8, 0 -> $s { ( $base +> $s ) +& 0xff; }
    ).join('.') ~ '/' ~ $mask;
   
    return $str;
}

Name: Anonymous 2011-10-07 2:21

I'm fucking amazed people actually use Basic.

Name: Anonymous 2011-10-07 3:35

lololol I'm C# and i am create object whilly nilly and i don't have to worry about cleaning it up again.

new
new
new
new
new

Thank you GC <3 You've saved me a lot of time and effort whilst I've been writing this 3D game engine. Daymn this thing has shadows, physics and al sorts of other shit. Imagine if I wrote this in C++, it would have taken aaaaages, best but is I can declare a portion of code as "Unsafe" and still use pointers.

I could have written it in lisp of course, but that would by far to slow for a proper games engine, that shit would be unusable.

Name: Anonymous 2011-10-07 4:06

>>44
I'm not sure if you're trying to troll users of garbagecollected languages, or just veeeeery butthurt

Name: Anonymous 2011-10-07 4:14

>>45
Not trolling, I've worked with C++ to make game engines and software renderers. C# makes it a lot easier on memory clean up thanks to the GC. The major downside being that the code is locked to windows platforms.

I guess Java gets around the platform issue, but Java sucks around 10 cocks a day.

Name: Anonymous 2011-10-07 4:17

>>34
I'm not sure whether you're trolling, but you don't need to do a loop. A switch without a default clause inside a loop for anything else than a finite-state machine or event handler is inefficient.
Also, I just realized that your code lacks break instructions.

Name: Anonymous 2011-10-07 4:22

>>46
How about Common Lisp?

Name: Anonymous 2011-10-07 4:41

Name: Anonymous 2011-10-07 5:07

>>49
Geçenlerde okuduğum ve gerçekten çok
It's in german.

Name: Anonymous 2011-10-07 6:07

>>50
he thinks turkish is german

laughing_bratwürste.jpg

Name: Anonymous 2011-10-07 7:31

Sorry, it's not English.

Option Explicit

const w = 3
const h = 3
const tyhja = "_"
redim TheGame(w,h)
dim fun
dim i, j
dim inp, x, y
dim view
dim merkki
dim winner
dim random_ok

view = ""
winner = "0"
fun = True
For i = 0 To w -1
  For j = 0 To h-1
    TheGame(i,j) = tyhja
  Next
Next
Randomize

msgbox "Super X0 !!!!!!!!!!!!!!!!!!111111oneoneelevenone" & vbCr & vbCr & "Paina OK, tampio"

Do While fun
  view = ""
  For i = 0 To h-1
    For j = 0 To w-1
      merkki = TheGame(j,i)
      view = view & merkki
      if merkki <> tyhja Then
        If i <> 0 and i <> h-1 Then
          if TheGame(j, i-1) = merkki and TheGame(j, i+1) = merkki Then
            winner = merkki
            fun = False
          End If
        End If
        If j <> 0 and j <> w-1 Then
          if TheGame(j-1, i) = merkki and TheGame(j+1, i) = merkki Then
            winner = merkki
            fun = False
          End If
        End If
        If j <> 0 and i <> 0 and i <> h-1 and j <> w-1 Then
          If (TheGame(j-1, i-1) = merkki and TheGame(j+1, i+1) = merkki) _
          Or (TheGame(j+1, i-1) = merkki and TheGame(j-1, i+1) = merkki) Then
          winner = merkki
          fun = False
        End If
      End If
    end if
  Next
  view = view & vbCr
Next
if fun then
  inp = InputBox(view)
  x = CInt(mid(inp, 1, 1)) - 1
  y = CInt(mid(inp, 2, 1)) - 1

  if TheGame(x,y) = tyhja then
    TheGame(x,y) = "X"
  end If

  random_ok = False
  do while not random_ok
    x = w * Rnd
    y = h * Rnd
    if TheGame(x, y) <> "0" Then
      TheGame(x,y) = "0"
      random_ok = True
    End If
  loop
end if
Loop

MsgBox winner & " voitti..."

Name: Anonymous 2011-10-07 7:33

I'm frightened to see some people actually do use BASIC.

Name: Anonymous 2011-10-07 7:36

>>53
Hey, that's vbs. I didn't have any compiler for that computer and I was bored.

Name: Anonymous 2011-10-07 9:40

Hey /frog/

Please criticize my C++ 2D-vector class. Implementation in header file for inlining.


#ifndef VEC2_H_INCLUDED_
#define VEC2_H_INCLUDED_

#include <cmath>

/**
 * Represents 2D vector.
 */
class Vec2
{
public:
    float x, y;
    /** Construct vector with given values */
    Vec2(float _x, float _y) : x(_x), y(_y) {}
    /** Create uninitialized vector */
    Vec2(){}
    /** Construct scaled copy */
    Vec2(const Vec2& v, float scale_ratio) {
        *this = v;
        scale(scale_ratio);
    }
    Vec2& operator += (const Vec2& v) {
        x += v.x;
        y += v.y;
        return *this;
    }
    Vec2& operator -= (const Vec2& v) {
        x -= v.x;
        y -= v.y;
        return *this;
    }
    Vec2 operator + (const Vec2& v) const {
        return Vec2(x+v.x, y+v.y);
    }
    Vec2 operator - (const Vec2& v) const {
        return Vec2(x-v.x, y-v.y);
    }
    /** multiply with scalar */
    void scale(float m) {
        x *= m;
        y *= m;
    }
    /** Dot product */
    float dot(const Vec2& v) const {
        return x * v.x + y * v.y;
    }
    /** Cross product */
    Vec2 cross(const Vec2& v) const {
        return Vec2(y - v.y, x - v.y);
    }
    float length() const {
        return std::sqrt(length2());
    }
    /** Square of length */
    float length2() const {
        return x*x + y*y;
    }
    /** Distance to other vector */
    float distance(const Vec2& v) const {
        return std::sqrt(distance2(v));
    }
    /** Distance to other vector squared */
    float distance2(const Vec2& v) const {
        float dx = x - v.x;
        float dy = y - v.y;
        return dx*dx + dy*dy;
    }
    /** Normalize vector. The length after normalization is 1 */
    void normalize() {
        scale(1 / length());
    }
    /** set new value */
    void set(float _x, float _y) {
        x = _x;
        y = _y;
    }
    /** Rotate vector by angle radians */
    void rotate(float angle) {
        float len = length();
        angle += atan2(y, x);
        x = cos(angle) * len;
        y = sin(angle) * len;
    }
    /** Create vector projection: u projected to *this */
    Vec2 projection(const Vec2& u) const {
        Vec2 p = *this;
        float len = length();
        p.scale(this->dot(u) / (len * len));
        return p;
    }
};

#endif

Name: Anonymous 2011-10-07 9:44

>>55
Please criticize my C++ 2D-vector class.
It's C++. Done.

Name: Anonymous 2011-10-07 13:04

>>54

just use JS then, it is in every browser.

Name: Anonymous 2011-10-07 15:55

I like the post code SW1A 0AA. (´・ω・)

Name: Anonymous 2011-10-07 16:52

59 GET

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List