Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

bindec.scm (See related posts)

// Convert list of 1s and 0s back to base ten number.

   1  
   2  ; Andrew Pennebaker
   3  ; 5 Feb 2007
   4  ; License: GPL
   5  ; URL: http://snippets.dzone.com/posts/show/3479
   6  
   7  (define bin->dec
   8  	(lambda (b)
   9  		(cond
  10  			((integer? b) b)
  11  			((= (length b) 0) 0)
  12  			(else
  13  				(+
  14  					(* (expt 2 (- (length b) 1)) (car b))
  15  					(bin->dec (cdr b)))))))

You need to create an account or log in to post comments to this site.


Click here to browse all 5827 code snippets

Related Posts