# Search the Community

Showing results for tags 'atom replace'.

• ### Search By Tags

Type tags separated by commas.

### Forums

• News, Announcements & FAQ
• Feedback
• AutoCAD Beginners' Area
• AutoCAD 2D Drafting, Object Properties & Interface
• AutoCAD Drawing Management & Output
• AutoCAD 3D Modelling & Rendering
• AutoCAD Vertical Products
• AutoCAD Bugs, Error Messages & Quirks
• The CUI, Hatches, Linetypes, Scripts & Macros
• AutoLISP, Visual LISP & DCL
• .NET, ObjectARX & VBA
• Application Beta Testing
• Application Archive
• Other Autodesk Products
• Autodesk 3ds Max
• Autodesk Revit
• Autodesk Inventor
• Autodesk Software General
• Other CAD Products
• SketchUp
• Rhino
• SolidWorks
• MicroStation
• Design Software
• Catch All
• Resources
• Tutorials & Tips'n'Tricks
• Blocks, Images, Models & Materials
• Community
• Introduce Yourself
• Showcase
• Work In Progress
• Jobs & Training
• Chat
• Competitions

### Categories

• Programs and Scripts
• 2D AutoCAD Blocks
• 3D AutoCAD Blocks
• Images
• Backgrounds

• 0 Replies

• 0 Reviews

• 0 Views

Found 1 result

1. ## nth-replace (mergesort's achilles heel)

I've completed MergeSort algorithm implementation in Autolisp based on Ellis Dee's vb6 version here: http://www.vbforums.com/showpost.php?p=2909257&postcount=12 The problem is that I need to replace nth atom in the lisp array, and the only way I can currently accomplish this, is by iterating the entire list. This takes, what would be a spectacular sorting algorithm, and destroys it's efficiency by iterating the list nth(log) times. I'm going to try not to muddy the water too much, but here is my nth-replace function based on Michels nth-remove function... (defun nth-replace (n_atom f_list f_n / ) ;replaced the nth element of a list ;n_atom is new atom ;f_list is list to be operated on ;f_n is the index that will be replaced (if (and (numberp f_n) (listp f_list)) (if (and (>= f_n 0) (< f_n (length f_list)) n_atom) (progn (repeat f_n (setq f_list (append (cdr f_list) (list (car f_list)))) ) (setq f_list (append (cdr f_list) (list n_atom))) (repeat (- (length f_list) f_n 1) (setq f_list (append (cdr f_list) (list (car f_list)))) ) ) ) ) f_list );defun I'm not completely new to autolisp, but I'm hoping there's a fundamental function I'm overlooking that can either replace an atom at a certain level, or can return a list up to a certain atom (nth instance), and then I can append my change, and then the latter half of the list.
×
×
• Create New...