Author Topic: Un Raytracer écrit en K (a variant of APL containing elements of Scheme)  (Read 2341 times)

0 Members and 1 Guest are viewing this topic.

Offline flngr

  • Base
    • View Profile
  • Ancienneté: -1
  • Groupe: adinpsz
  • Rôle: unfinished intros champion
  • Ville: Paris
Code: [Select]
/ http://www.ffconsultancy.com/free/ray_tracer/comparison.html   hit 18 upper 6 leaf of 1325
s:(-3 3 -3 3;3 3 3 3;-3 -3 3 3)%sqrt 12;C:{[k;c;r]$[k-:1;((c;r*3);(,(c;r)),C[k;;r%2]'+c+r*s);(c;r)]}
s:C[6;0 -1 0.;1.];u:{x%sqrt x wsum x};e:%m:1e9;l:u 1 3 -2;b:0 0 -4.                        /scene
d:{[v;s]$[0>d:(n*n:c wsum v 1)-(c wsum c:(*s)-*v)-d*d:s 1;m;n>e+d:sqrt d;n-d;n>e-d;n+d;m]} /distance
i:{[v;m;s]$[@*s;$[(*m)>a:d[v;s];(a;*s);m];(*m)>d[v;*s];m i[v]/s 1;m]}                      /intersect
t:{[v;s]$[m=d:*r:i[v;m;s];0.;0>g:l wsum n:u(b:v[0]+d*v 1)-r 1;0.;m=*i[(b;l);m;s];g;0.]}    /trace
 
j:(&4 4 4 4)%4;k:16#(!4)%4;n:16
\t r:(|r){+/t[;s]'(b;)'u'+(x+j-n%2;y+k-n%2;n+16#0.)}\:/:r:!n
 


http://en.wikipedia.org/wiki/K_(programming_language)

Quote
The small size of the interpreter and compact syntax of the language makes it possible for K applications to fit entirely within the level 1 cache of the processor. Vector processing makes efficient use of the cache row fetching mechanism and posted writes without introducing bubbles into the pipeline by creating a dependency between consecutive instructions.
« Last Edit: 30 September 2010 à 11:08:22 by flngr »

ponce

  • Guest
On dirait du R en pire  :D

Offline flngr

  • Base
    • View Profile
  • Ancienneté: -1
  • Groupe: adinpsz
  • Rôle: unfinished intros champion
  • Ville: Paris
Dans le même genre, le J :

Code: [Select]
  quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
http://en.wikipedia.org/wiki/J_(programming_language)

Quote
Tacit programming involves composing functions together and not referring explicitly to any variables. J's support for forks and hooks dictates rules on how arguments applied to this function will be applied to its component functions.
http://en.wikipedia.org/wiki/Tacit_programming