+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Forum Newbie
    Using
    not applicable
    Join Date
    Jul 2012
    Posts
    2

    Default LISP count alphabet

    Registered forum members do not see this ad.

    Learnt all numbers in a list, all alphabets in a list.
    but how if both in the same?

    such as
    (count-alpha '(8 0 b 7 h u 6 d ) ) -> 4
    (count-no '(8 0 b 7 h u 6 d ) ) -> 4

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,138

    Default

    Your request looks vaguely familiar. I swear that someone posted this same question recently. Try a search on the word "alphabet".
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  3. #3
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Things like this ...

    Code:
    (mapcar (function (lambda (x)
                        (if (numberp x)
                          (setq n (cons x n))
                          (setq a (cons x a))
                        )
                      )
            )
            '(8 0 b 7 h u 6 d)
    )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Anther with the use of foreach function ....

    Code:
    (foreach item '(8 0 b 7 h u 6 d)
      (if (numberp item)
        (setq numbers (cons item numbers))
        (setq alpha (cons item alpha))
      )
    )
    Would return the same result as the first codes .

    numbers = ( 6 7 0 8 )
    alpha = ( D U H B )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Code:
    (defun count-alpha ( l )
        (length (vl-remove-if 'numberp l))
    )
    (defun count-no ( l )
        (length (vl-remove-if-not 'numberp l))
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Forum Newbie
    Using
    not applicable
    Join Date
    Jul 2012
    Posts
    2

    Default

    Code:
    (mapcar (function (lambda (x)                     (if (numberp x)                       (setq n (cons x n))                       (setq a (cons x a))                     )                   )         )         '(8 0 b 7 h u 6 d) )
    Error: Attempt to take the value of the unbound variable `N'.
    [condition type: UNBOUND-VARIABLE]


    Code:
    (foreach item '(8 0 b 7 h u 6 d)   (if (numberp item)     (setq numbers (cons item numbers))     (setq alpha (cons item alpha))   ) )
    Error: attempt to call `FOREACH' which is an undefined function.
    [condition type: UNDEFINED-FUNCTION]


    Code:
    (defun count-alpha ( l )
        (length (vl-remove-if 'numberp l))
    )
    (defun count-no ( l )
        (length (vl-remove-if-not 'numberp l))
    )
    Error: attempt to call `VL-REMOVE-IF' which is an undefined function.
    [condition type: UNDEFINED-FUNCTION]

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,007

    Default

    What CAD application are your using in fact?!? Those don't appear as AutoLISP error messages...
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  8. #8
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,007

    Default

    Or are you talking in fact of LISP language? Then please pay attention that this Forum is dedicated to AutoLISP, a dialect of LISP used under AutoCAD editor; so I'm afraid that will have to find other resource for help on your issue.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  9. #9
    Senior Member Lee Roy's Avatar
    Computer Details
    Lee Roy's Computer Details
    Operating System:
    Windows 7 Professional 64-bit
    Computer:
    HP Z400
    CPU:
    Intel Xeon W 3565 @ 3.2GHz
    RAM:
    16GB
    Graphics:
    ATI FirePro V5900
    Primary Storage:
    OCZ Vertex 4 - 256GB - Sata III - SSD
    Secondary Storage:
    Seagate Barracuda 1TB 7200rpm
    Monitor:
    Dual - HP Compaq LA2405wg
    Discipline
    Multi-disciplinary
    Lee Roy's Discipline Details
    Occupation
    CAD/BIM Manager
    Discipline
    Multi-disciplinary
    Details
    Architectural, Mechanical, Plumbing, Electrical...JOAT
    Using
    Revit 2014
    Join Date
    Apr 2011
    Location
    Visalia, CA
    Posts
    417

    Default

    It appears to be an error message formatting from the Common Lisp language.
    "The thing about quotes on the internet is that you cannot confirm their validity." - Abraham Lincoln
    I -edit- a lot, sorry.
    The rotary engine is the most efficient way of converting fuel to noise ever invented.
    If my post sounds offensive, but can be meant in a non-offensive manner...I meant the latter.

  10. #10
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,634

    Default

    Registered forum members do not see this ad.

    In which case: Using ECL's Lisp Shell:
    Code:
    (length (remove-if-not (lambda (a) (stringp a)) '(1 3 6 "34" 5 "name")))
    2
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

Similar Threads

  1. Lisp to count blocks on specific layers
    By chee_dee in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 9th Feb 2013, 07:49 am
  2. Lisp: How do I count the items in a list?
    By ajs in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 9th Feb 2009, 08:43 pm
  3. Dreamweaver CS3-Hit count
    By KnoJa31 in forum Web Design
    Replies: 5
    Last Post: 13th Oct 2008, 09:17 am
  4. Replies: 10
    Last Post: 12th May 2007, 11:35 pm
  5. Text Count
    By johnengineer in forum AutoCAD General
    Replies: 4
    Last Post: 21st Mar 2007, 01:52 am

Tags for this Thread

Bookmarks

Posting Permissions

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