See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: Newby in LISP for translating macro into C++

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2020-03
    Posts
    1
    Login to Give a bone
    0

    Default Newby in LISP for translating macro into C++

    Hello,
    I'm a newby in LISP. Indeed, I'm translating some LISP code into C++. This is fairly simple for functions (there are all mathematical functions, so very simple to test the validity of my translation). However, I'm blocked for 3 macro.

    Is somebody could help me to translate into C/C++ ?

    Thanks beforehand
    Code:
    (defmacro binary-search (l lo h hi x test end)
      ;; TYPE (* real * real * (real->boolean)
      ;; TYPE  ((real real)->boolean)) -> real
      ;; Bisection search for $x$ in [$lo$..$hi$] such that
      ;; $end$ holds.  $test$ determines when to go left.
      (let* ((left (gensym)))
        `(do* ((,x false (/ (+ ,h ,l) 2))
               (,left false ,test)
               (,l ,lo (if ,left ,l ,x))
               (,h ,hi (if ,left ,x ,h)))
              (,end (/ (+ ,h ,l) 2)))))
    
    (defmacro invert-angular (f y r)
      ;; TYPE (real->angle real interval) -> real
      ;; Use bisection to find inverse of angular function
      ;; $f$ at $y$ within interval $r$.
      (let* ((varepsilon 1/100000)); Desired accuracy
        `(binary-search l (begin ,r) u (end ,r) x
                        (< (mod (- (,f x) ,y) 360) (deg 180))
                        (< (- u l) ,varepsilon))))
    
    (defmacro sigma (list body)
      ;; TYPE (list-of-pairs (list-of-reals->real))
      ;; TYPE  -> real
      ;; $list$ is of the form ((i1 l1)...(in ln)).
      ;; Sum of $body$ for indices i1...in
      ;; running simultaneously thru lists l1...ln.
      `(apply '+ (mapcar (function (lambda
                                     ,(mapcar 'car list)
                                     ,body))
                         ,@(mapcar 'cadr list))))
    Last edited by BlackBox; 2020-03-23 at 03:37 PM. Reason: Please use [CODE] Tags

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    1

    Default Re: Newby in LISP for translating macro into C++

    I'm not saying there is noone here to help you, but this is not valid AutoLISP code. This forum is intended for AutoCAD based AutoLISP which does not include some of the functions your code uses.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Newby in LISP for translating macro into C++

    It looks like pure lisp as opie has said, there used to be a lisp to C converter when Autodesk went to ADS but that was like R12. Google for it may help.

    Did you google for a C# your function example code.

Similar Threads

  1. printing issue - newby
    By pshupe in forum Revit Architecture - General
    Replies: 0
    Last Post: 2009-10-06, 01:57 PM
  2. newby - how to make/insert 2d blocks
    By pshupe in forum Revit Architecture - General
    Replies: 1
    Last Post: 2009-04-17, 06:32 PM
  3. Wall Layers ( was> Newby Question )
    By mrd.84339 in forum Revit Architecture - General
    Replies: 6
    Last Post: 2005-04-15, 05:31 PM
  4. translating revit drawings into autocad layers
    By bnix in forum Revit Architecture - General
    Replies: 4
    Last Post: 2005-01-20, 09:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •