루시드 (프로그래밍 언어)

위키백과, 우리 모두의 백과사전.

루시드
Lucid
패러다임데이터플로
설계자에드워드 A. 애시크로프트
윌리엄 W. 웨지
발표일1976년
자료형 체계Typeless
주요 구현체
pLucid
방언
GIPSY, Granular Lucid
영향을 받은 언어
ISWIM
영향을 준 언어
SISAL, PureData, Lustre

루시드(Lucid)는 폰 노이만 구조를 따르지 않는 프로그래밍 모델을 갖춘 실험적으로 설계된 데이터플로 프로그래밍 언어이다. 빌 웨지(Bill Wadge)와 에드 애시크로프트(Ed Ashcroft)에 의해 설계되었으며 1985년 책 "데이터플로 프로그래밍 언어, 루시드"(Lucid, the Dataflow Programming Language)에 기술되었다.[1]

pLucid는 루시드를 위한 최초의 인터프리터이다.

예시[편집]

계승[편집]

fac
  where
    n = 0 fby (n + 1);
    fac = 1 fby ( fac * (n + 1) );
  end

피보나치 수[편집]

fib
  where
    fib = 0 fby ( 1 fby fib + next fib );
  end

소수[편집]

prime
  where
     prime = 2 fby (n whenever isprime(n));
     n = 3 fby n+1;
     isprime(n) = not(divs) asa divs or prime*prime > N
                     where
                       N is current n;
                       divs = N mod prime eq 0;
                     end;
  end

데이터 흐름도[편집]

퀵 정렬[편집]

qsort(a) = if eof(first a) then a else follow(qsort(b0),qsort(b1)) fi
  where
     p = first a < a;
     b0 = a whenever p;
     b1 = a whenever not p;
     follow(x,y) = if xdone then y upon xdone else x fi
                     where
                        xdone = iseod x fby xdone or iseod x;
                     end
  end

데이터 흐름도[편집]

    --------> whenever -----> qsort ---------
   |             ^                           |
   |             |                           |
   |            not                          |
   |             ^                           |
   |---> first   |                           |
   |       |     |                           |
   |       V     |                           |
   |---> less ---                            |
   |             |                           |
   |             V                           V
---+--------> whenever -----> qsort -----> conc -------> ifthenelse ----->
   |                                                       ^   ^
   |                                                       |   |
    --------> next ----> first ------> iseod --------------    |
   |                                                           |
    -----------------------------------------------------------

제곱평균제곱근[편집]

sqroot(avg(square(a)))
  where
     square(x) = x*x;
     avg(y)    = mean
        where
          n = 1 fby n+1;
          mean = first y fby mean + d;
          d = (next y - mean)/(n+1);
        end;
     sqroot(z) = approx asa  err < 0.0001
        where
          Z is current z;
          approx = Z/2 fby (approx + Z/approx)/2;
          err    = abs(square(approx)-Z);
        end;
   end

각주[편집]

  1. Wadge, William W.; Ashcroft, Edward A. (1985). 《Lucid, the Dataflow Programming Language》. Academic Press. ISBN 0-12-729650-6. 2015년 1월 8일에 확인함. 

외부 링크[편집]