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

Common Lisp in C

Name: Anonymous 2012-10-03 17:23

Lets write Common Lisp functions in generic C code.


/* (map #'func array) => map(array,length_of_array,sizeof(array),function_pointer) */
void *map(void *base,size_t len,size_t elemnsize, void (*func)(void *,void *)) {
  void *b = malloc(elemsize*len);
  size_t i;
  for(i=0;i<len;++i){
    func(b+(elemsize*1),base);
    base += elemsize;
  }
  return b;
}

Name: Anonymous 2012-10-04 22:12

When did people start hating anti-jew posts?

Name: Anonymous 2012-10-04 22:43

>>41
Since when they became "people"?

Name: Anonymous 2012-10-04 22:45

>>40
Shåløm! Unicode is BIG.

Name: Anonymous 2012-10-04 23:15

>>40
>>39
Shalom!

Name: Anonymous 2012-10-05 19:49

>>23
This isn't what he's suggesting, that is what I am suggesting.

>>24
Can i use this in C89/99?
You can use the map macro, but you won't really gain any thing over just a for loop. You obviously can't use the nested function thing, that's GCC specific.

How does gcc handle scope names if i named another variable _i when using the that?
Just like it would any other scope, it works fine.

>>26
It's O(n) slower than not doing anything at all, and this is noticeable  when you don't have to do it.

Name: Anonymous 2013-09-01 10:49



                rァ=-、_     ,.rァ‐-、
        rr-‐rァ    「/::::::::::ヽ!、    i/:::::::/7
        Y::::::〈!     '、!'⌒ヽ、_y'ー、,/::::::/!7
        ヽ;::::ヽ     ,!>-ァ'ヽr-ヘト、ン/:::::!'
    /    !}::::!{ ,.. '"´く::::/}      `y^i'ー'^ヽ.   目が回るぅ~
   .,'      ヽゝ/    Y-'      /:::!{  、 ヽ.
   i  , '"´   'y'  ./  /!   ,'  ,  く:;__」}   ':,  '、
          ;'  ./   /ー!--! /'!   ハ  ',   ',ヽ、',
     i´`ヽ.,  L__;'  _/,.',ニ、ヽレ'  ! ァ'ー!-'、! i  i:::::: `'' ー-‐=ァ
    ,.、_!,   ヽ.  `>、,ハ.! !,_ー' ノ  レ' ,.',ニ、ヽ.! !  i`ヽ、:::::::::::::/
    ヽ、,___   `'ァ'   7' `'ー‐'      ! !,_ー' ノr┴-、!  ,' `ー='
       `ヽ、, '   .イ⊃ ,.-_、.,,__   `'ー‐' /   !   /
          /   .ノゝ、i´     ̄`ヽ. ⊂⊃ .,'  /
         ,'   ,.イ   /!>.、.,__  __,!,. イ   ,:' イ
         !___/_ノ!__,,...'-‐''"´   ̄    ./ヽ、ノ    ',    .!
   (     }i::::::`r、_,,. -‐rァ、.,,________,,,,... イ _,rメ、!7、   !   ,'
    `"'' ー }レ'7へ:::::::::::!{><:::::::i    rン'::::::::::ヾ!  ノ   ノ
         (.  ン^ヽ、」}ニ<:::::::::i   r/!::::_r'" ̄ヽ!_    ´
      rァー_r)'":::::ヽ;ヽ、::::::::::::::;:イ!__,/::!ヤ、__'、   7'iーァ、,__,,.. -‐ァ
    _rァ''"´:::::::::::::::/`ーヘ、__二ン::::::::::::::::::`'く >.、.,!/::/ `ヽ:::::/」
   ノ」:::::::::::::::::::::'´:::::::::::/::::::::::::::!::::::,.-‐‐-::::::: `ヽ.   `ヽ、)、___ノ ̄
    !ヘ;:::::::::::::::::::::::::::::::::::::::::::::::::::γ::: y'⌒ヽ:::::::::::::':,         __
    ヽ,へ:::::::::::::::::::::::::::::::::::::::::::::::i:::::::!::::ー- ':::!:::::::::::::',      - 、 `ヽ.
    /;:-X::>、:;__::::::::::::::::::::::::::::::メ::::::::ゝ、;__ ノ::::::::::::::::〉、   ___,,..ノ  ノ
    ,'::::::::::/`'' ー、,'^ヽ、:;____:::::::メ::::::::___::::______:::_;;:::イ ン'
 ( ( `' ー'        ̄`"'ー-、.,_二ン'-r'"ー-‐'"    ̄
                  |::::X:::7
                  !:::::::::;'
                  `'ー-'

Name: Anonymous 2013-09-01 11:02

>>45
It's about O(n/c + k) where k is at most 1/500 the time it takes a neuron to fire and c in the thousands. You won't—can't—notice it unless n is astronomical.

What's slow is managing that memory. Which is waaaaaaaay more than O(n) if it contains pointers or lives for any appreciable amount of time.

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