Author Topic: null string in list  (Read 10342 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: null string in list
« Reply #45 on: August 05, 2015, 04:07:10 PM »
Another:
Code - Auto/Visual Lisp: [Select]
  1. (defun f4 ( l )
  2.     (not (while (= "" (car l)) (setq l (cdr l))))
  3. )
Comando: (f4 '("1" "" "" "" ""))
T
 :wink:

 :-(

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: null string in list
« Reply #46 on: August 05, 2015, 09:18:42 PM »
@ Marc'Antonio Alessi, thanks these comparisons are interesting, but I find it hard to do ..

alist0 = alistE – 1  Performance comparison
And if alistS very long and it is more difficult for the vl-remove function

Regards,
PS: A list is infinite, how can we say that the list is long?
ok... other  tests:
Code: [Select]
(setq alist0 '(""  "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""))
(setq alist0 (repeat nn (setq alist0 (append alist0 alist0)))) ;nn max = 12
(setq alistS (append '("1") alist0 alist0))
(setq alistE (append alist0 alist0 '("1")))
(setq alistM (append alist0 '("1") alist0))
(setq alist0 (append '("")  alist0 alist0))

length: 8192
Elapsed milliseconds / relative speed for 16384 iteration(s):
    (VL-REMOVE1 ALIST0)......1969 / 16.92 <fastest>
    (APPLY1 ALIST0)..........4547 / 7.33
    (F2 ALIST0)..............6500 / 5.13
    (VL-EVERY12 ALIST0).....13000 / 2.56
    (APPLY3 ALIST0).........14281 / 2.33
    (APPLY2 ALIST0).........14391 / 2.31
    (F_VDH ALIST0)..........25625 / 1.3
    (F6 ALIST0).............33313 / 1 <slowest>

length: 32768
Elapsed milliseconds / relative speed for 4096 iteration(s):
    (VL-REMOVE1 ALIST0)......1610 / 7.15 <fastest>
    (APPLY1 ALIST0)..........4015 / 2.87
    (F2 ALIST0)..............6157 / 1.87
    (VL-EVERY12 ALIST0).....10875 / 1.06
    (APPLY2 ALIST0).........11500 / 1
    (APPLY3 ALIST0).........11516 / 1 <slowest>

length: 131073
Comando: (f7 alist0)
; errore: valore dell'argomento errato: does not fit in byte: 131073

Elapsed milliseconds / relative speed for 1024 iteration(s):
    (VL-REMOVE1 ALIST0)......1656 / 7.6 <fastest>
    (APPLY1 ALIST0)..........4234 / 2.97
    (VL-EVERY12 ALIST0).....11343 / 1.11
    (APPLY2 ALIST0).........11406 / 1.1
    (APPLY3 ALIST0).........11422 / 1.1
    (F2 ALIST0).............12578 / 1 <slowest>

length: 2049
Elapsed milliseconds / relative speed for 131072 iteration(s):
    (VL-EVERY12 ALISTS)......1109 / 28.32 <fastest>
    (APPLY1 ALISTS)..........2297 / 13.67
    (VL-REMOVE1 ALISTS)......4250 / 7.39
    (F2 ALISTS).............14937 / 2.1
    (APPLY2 ALISTS).........29297 / 1.07
    (APPLY3 ALISTS).........31406 / 1 <slowest>

length: 2049
    (VL-REMOVE1 ALISTE).....1234 / 7.64 <fastest>
    (APPLY1 ALISTE).........2657 / 3.55
    (F2 ALISTE).............4187 / 2.25
    (VL-EVERY12 ALISTE).....6594 / 1.43
    (APPLY2 ALISTE).........9375 / 1.01
    (APPLY3 ALISTE).........9422 / 1 <slowest>

length: 8193
Elapsed milliseconds / relative speed for 262144 iteration(s):
    (VL-EVERY12 ALISTS)......1985 / 48.43 <fastest>
    (APPLY1 ALISTS).........11875 / 8.1
    (VL-REMOVE1 ALISTS).....27015 / 3.56
    (F2 ALISTS).............96141 / 1 <slowest>

length: 8193
Elapsed milliseconds / relative speed for 16384 iteration(s):
    (VL-REMOVE1 ALISTE)......1688 / 6.56 <fastest>
    (APPLY1 ALISTE)..........4187 / 2.65
    (F2 ALISTE)..............6079 / 1.82
    (VL-EVERY12 ALISTE).....11078 / 1 <slowest>

length: 262145
Elapsed milliseconds / relative speed for 512 iteration(s):
    (VL-REMOVE1 ALIST0).....1609 / 2.55 <fastest>
    (APPLY1 ALIST0).........4109 / 1 <slowest>

Elapsed milliseconds / relative speed for 1024 iteration(s):
    (APPLY1 ALISTS).........1391 / 2.39 <fastest>
    (VL-REMOVE1 ALISTS).....3329 / 1 <slowest>

Elapsed milliseconds / relative speed for 512 iteration(s):
    (VL-REMOVE1 ALISTE).....1625 / 2.5 <fastest>
    (APPLY1 ALISTE).........4063 / 1 <slowest>

Elapsed milliseconds / relative speed for 512 iteration(s):
    (VL-REMOVE1 ALISTM).....1609 / 1.5 <fastest>
    (APPLY1 ALISTM).........2406 / 1 <slowest>

bruno_vdh

  • Guest
Re: null string in list
« Reply #47 on: August 06, 2015, 03:11:39 AM »
Comprehensive testing, thank you for your sharing.
Regards,


bruno_vdh

  • Guest
Re: null string in list
« Reply #49 on: August 06, 2015, 04:17:25 AM »
length: 131073
Comando: (f7 alist0)
; errore: valore dell'argomento errato: does not fit in byte: 131073

Yes it is known and that's why I'm always very wary with the use of the eval function to replace apply.
3 reasons to be wary:


The symbolic arguments are evaluated 
Code: [Select]
$ (eval  (cons '=  '(A B C D)))
T
http://www.theswamp.org/index.php?topic=49884.msg550800#msg550800


The number of arguments is limited
Code: [Select]
_$ (length (repeat 255 (setq L255 (cons 1 L255))))
255
_$ (eval (cons '+ (cons 1 L255)))
; erreur: limite interne: nombre d'arguments trop important dans l'appel de la fonction: +
http://cadxp.com/topic/39608-fonctions-et-%e2%80%93-limite-a-255-arguments/page__view__findpost__p__220345


With this writing, the special form are not supported
Code: [Select]
_$ ((eval 'and) T T)
; erreur: Impossible d'appliquer la feuille spéciale: AND
http://www.theswamp.org/index.php?topic=49859.msg550438#msg550438

Regards,
(Ps: I speak with an automatic translator, I hope that the translation is good, sorry)
« Last Edit: August 06, 2015, 05:16:32 AM by bruno_vdh »

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: null string in list
« Reply #50 on: August 06, 2015, 07:22:44 AM »
Another slightly different.

Code - Auto/Visual Lisp: [Select]
  1. (apply 'and (mapcar '(lambda (x) (eq x "")) '("" "" "" "" "")))
  2.