pouët.net

Random line of code thread

category: code [glöplog]
and if you remove
Code:div _ Null = error "div _ Null"
then dividing by zero (Null here for those don't understand the code) is just an infinite loop. Drunk haskell coding is fun!
added on the 2009-11-01 04:45:47 by tobé tobé
Code:------------------------------------------------------------------------------- module Unary2 ( ------------------------------------------------------------------------------- Unary (Null, Unary), Number (inc, dec, add, sub, mul, div), from_int, to_int ) where ------------------------------------------------------------------------------- import qualified Prelude as Impure ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- data Unary = Null | Unary Unary deriving Impure.Show ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- from_int :: Impure.Int -> Unary ------------------------------------------------------------------------------- from_int x | (x Impure.== 0) = Null | (x Impure.> 0) = Unary (from_int (x Impure.- 1)) | (x Impure.< 0) = Impure.error "from_int x | (x < 0)" ------------------------------------------------------------------------------- to_int :: Unary -> Impure.Int ------------------------------------------------------------------------------- to_int Null = 0 to_int (Unary x) = (to_int x) Impure.+ 1 ------------------------------------------------------------------------------- class Number a where ------------------------------------------------------------------------------- inc :: a -> a dec :: a -> a add :: a -> a -> a sub :: a -> a -> a mul :: a -> a -> a div :: a -> a -> a ------------------------------------------------------------------------------- instance Number Unary where ------------------------------------------------------------------------------- --------------------------------------------------------------------------- inc x = Unary x --------------------------------------------------------------------------- --------------------------------------------------------------------------- dec Null = Impure.error "dec Null" dec (Unary x) = x --------------------------------------------------------------------------- --------------------------------------------------------------------------- add Null y = y add x Null = x add x (Unary y) = Unary (add x y) --------------------------------------------------------------------------- --------------------------------------------------------------------------- sub Null _ = Impure.error "sub Null _" sub x Null = x sub (Unary x) (Unary y) = sub x y --------------------------------------------------------------------------- --------------------------------------------------------------------------- mul Null _ = Null mul _ Null = Null mul x (Unary y) = add (mul x y) x --------------------------------------------------------------------------- --------------------------------------------------------------------------- div x y = Unary (rdiv x y Null) where --------------------------------------------------------------------------- ----------------------------------------------------------------------- rdiv :: Unary -> Unary -> Unary -> Unary ----------------------------------------------------------------------- rdiv Null _ _ = Null rdiv x Null r = Unary (rdiv x r Null) rdiv (Unary x) (Unary y) r = rdiv x y (Unary r)

Time to go to bed...
added on the 2009-11-01 06:13:25 by tobé tobé
Code:GetPattern(psize)->AddColumn(new Column<float>, sizeof (float));
added on the 2009-11-01 09:00:26 by rudi rudi
Code:$table[$source[$i+0]][$source[$i+1]][$source[$i+2]]=$source[$i+3];
added on the 2009-11-01 09:53:06 by rmeht rmeht
wanna has some rings in sphere_tracing ?

return max(abs(length(p.xz)-r)-r2,abs(p.y)-c);

where:

r== radius ( ofcoz! )
r2 == the inner radius, but starting from the outer radius=r ! ( so its the difference from outer to inner radius! )
c == width of ring

otto must be proud ! ( --> lip-shitz )

return max(abs(length(p.xy)-r)-r2,abs(p.z)-c);
return max(abs(length(p.yz)-r)-r2,abs(p.x)-c);

^^ those are possible aswell ofcoz ;)
tobé : c'est du haskell ?
added on the 2009-11-01 11:38:57 by ponce ponce
Code: move.l #"FUCK",$80.w


There, a random LINE(!) of code.
added on the 2009-11-01 11:42:10 by StingRay StingRay
@#ponce: yes :)
added on the 2009-11-01 11:46:57 by tobé tobé
Yay :)

BB Image
Code:data Unary = Null | Positive Unary | Negative Unary deriving Impure.Show

Finally, i didn't sleep at all ><
added on the 2009-11-01 12:18:38 by tobé tobé
BB Image
added on the 2009-11-02 20:59:54 by harism harism
graga:


float plane(float3 p)
{
return p.y-sin(p.x*.5)*sin(sin(p.z*.5)*2.+time_0_X*2.4)*.4;
}

float sphere(float3 p, float r)
{
return length(p) - r;
}

float cylinder(float3 p,float r,float c)
{
return max(p.y-c,length(p.xz)-(r-p.y/c));
}

float ring(float3 p,float r,float r2,float c)
{
return max(abs(length(p.xz)-r)-r2,abs(p.y)-c);
}

float torus(float3 p,float r,float r2)
{
return length(float2(length(float2(p.x,p.z))-r,p.y))-r2;
}

float cube(float3 p, float3 r)
{
return max(max(abs(p.x) - r.x, abs(p.y) - r.y), abs(p.z) - r.z);
}

float octahedron(float3 p, float size)
{
p=abs(p);
return (p.x+p.y+p.z-size)/3;
}


HAVE FUN! ( ok, i fucked up the plane already :P )
also this could be helpful:

D3DXMATRIX mat_World;

float rotare[3]={ D3DXToRadian(180*ASMcosf(timez*.9f)), D3DXToRadian(270*ASMsinf(timez*.7f)), D3DXToRadian(360*ASMcosf(timez*.6f)) };

D3DXMatrixRotationYawPitchRoll( &mat_World, rotare[0],rotare[1],rotare[2] );
DX_Effect->SetMatrix( "matCamera", &mat_World );



shader-main:

"float4 main(float2 tc: TEXCOORD0) : COLOR0"
"{"
"float3 rayDirection = normalize(float3(tc*5., 1.));" // wrong xy.fisheye

"rayDirection = mul(float4(rayDirection.xyz, 0.), matCamera).xyz;"
[...]
ontop dont forget:

"float4x4 matCamera;"

LDA #$00
added on the 2009-11-03 02:04:22 by chriz74 chriz74
Code:return OfTheJedi;
Code: for (j=0; j<NSCAN/4; j++) { xr0 = spu_shuffle(xrl, xrl, S_0000) + (y-y0) * dxr0; xr1 = spu_shuffle(xrl, xrl, S_1111) + (y-y0) * dxr1; xl0 = spu_shuffle(xrl, xrl, S_2222) + (y-y0) * dxl0; xl1 = spu_shuffle(xrl, xrl, S_3333) + (y-y0) * dxl1; zl0 = spu_shuffle(zll, zll, S_0000) + (y-y0) * dzl0; zl1 = spu_shuffle(zll, zll, S_1111) + (y-y0) * dzl1; ll0 = spu_shuffle(zll, zll, S_2222) + (y-y0) * dll0; ll1 = spu_shuffle(zll, zll, S_3333) + (y-y0) * dll1; cmpr = spu_cmpgt(xr0, xr1); cmpl = spu_cmpgt(xl1, xl0); xr = spu_sel(xr0, xr1, cmpr); xl = spu_sel(xl0, xl1, cmpl); zl = spu_sel(zl0, zl1, cmpl); ll = spu_sel(ll0, ll1, cmpl); xri = spu_convts(xr+h, 0); xli = spu_convts(xl+h, 0); xri = spu_sel(xri, xmax, spu_cmpgt(xri, xmax)); xli = spu_sel(xli, zero, spu_cmpgt(zero, xli)); xri &= spu_cmpgt(y1, y) & spu_cmpgt(y, y0); xlf = spu_convtf(xli, 0)+h-xl; zl += xlf * dz; ll += xlf * dl; shad(b, zb + 0*MAX_WIDTH/4, spu_extract(xli, 0), spu_extract(xri, 0), spu_extract(zl, 0), dzf, spu_extract(ll, 0), dlf, color); b += sped.pitch/sizeof(vec_uint4); shad(b, zb + 1*MAX_WIDTH/4, spu_extract(xli, 1), spu_extract(xri, 1), spu_extract(zl, 1), dzf, spu_extract(ll, 1), dlf, color); b += sped.pitch/sizeof(vec_uint4); shad(b, zb + 2*MAX_WIDTH/4, spu_extract(xli, 2), spu_extract(xri, 2), spu_extract(zl, 2), dzf, spu_extract(ll, 2), dlf, color); b += sped.pitch/sizeof(vec_uint4); shad(b, zb + 3*MAX_WIDTH/4, spu_extract(xli, 3), spu_extract(xri, 3), spu_extract(zl, 3), dzf, spu_extract(ll, 3), dlf, color); b += sped.pitch/sizeof(vec_uint4); y = y + spu_splats(4.0f); zb += MAX_WIDTH; }
added on the 2009-11-03 12:32:09 by zerkman zerkman
Code:public double penetration;
Code:echo "Hello world";
added on the 2009-11-03 17:25:41 by harism harism
movep.l d4,-7(a1) ; (6) $ffff8203/05/07/09
added on the 2009-11-03 22:12:29 by Dbug Dbug
Code: bfffo d0{0:8},d1 ; decode drawing mode
added on the 2009-11-04 09:37:22 by StingRay StingRay
Code:Star* trek = new Generation();
added on the 2009-11-04 12:27:09 by zerkman zerkman
Code:// THIS IS SPARTAAAA!!1
added on the 2009-11-04 12:32:40 by harism harism
this->is = new S();
added on the 2009-11-04 14:04:45 by raer raer
--Use Artigos

--Create database Artigos
--Create table T_Pessoa
--(
--BI int not null,
--Nome char (50),
--Idade int,
--Sexo char (50),
--[Codigo Postal] int,
--)

--Create table T_Artigo
--(
--CodigoArtigo int not null,
--Descricao char(50),
--Precovenda money,
--Datafabrico date,
--BI_Pessoa int,
--)

--alter table T_Pessoa
--add constraint pk_BI primary key (BI)

--alter table T_Artigo
--add constraint pk_CodigoArtigo primary key (CodigoArtigo)

--alter table artigo
--add constraint fk_bi
--foreign key (BI_pessoa)
--references pessoa(BI)

--alter table artigo
--add constraint c_restricao check (BI>0)

--alter table pessoa
--add constraint c_sexorestricao check (Sexo in ('M','F'))

login