Short and sweet
Posted: Wed Apr 05, 2006 12:35 am
I love it when I find something rediculously simple that I smack myself on the head wondering why it took me so long. Here it is
(define (len=? lst n)(= (length lst)(if n n 1)))
I would say over 90% of the time all I ever do with the length function is to test if a list is equal to a certain amount. You will note that if you don't supply a number the list is tested to see if it has 1 element.
Anyone else have short but sweet function that they have discovered?
(define (len=? lst n)(= (length lst)(if n n 1)))
I would say over 90% of the time all I ever do with the length function is to test if a list is equal to a certain amount. You will note that if you don't supply a number the list is tested to see if it has 1 element.
Anyone else have short but sweet function that they have discovered?