aleix's blog

The Law of Car

10 April 2013 8:18 am (scheme | guile)

In The Little Schemer, The Law of Car is defined as:

The primitive car is defined only for non-empty lists.

In the implementation given for (firsts l), it seems to me that the law is broken:

(define firsts
  (lambda (l)
    (cond
      ((null? l) '())
      (else (cons (car (car l))
                  (firsts (cdr l)))))))

As (firsts '()) is '(). So, this would actually fail (in guile):

$ (firsts '((a b) () (e f)))
In procedure firsts:
In procedure car: Wrong type argument in position 1 (expecting pair): ()

I think a correct implementation would be (note that there's no need to write the second cond as the first cond could take multiple clauses):

(define (firsts l)
  (cond
   ((null? l) '())
   (else (cond
          ((null? (car l)) (firsts (cdr l)))
          (else
           (cons (car (car l))
                 (firsts (cdr l))))))))

in which we take care of the non-empty list before getting the first typical element (car (car l)). This would result in:

$ (firsts '((a b) () (e f)))
(a e)

62 responses

  1. assignment writing service says:

    Thank you for your post. I think this post definitely will help students ,especially for programing students.I hope students will easily catch your ideas so that it would become the step by step blog.

  2. Sociology Online Assignment Help says:

    Your blog is filled with unique good articles! I was impressed how well you express your thoughts and sharing your experiences.I never regretted any moment that came to your blog! :)

  3. MyAssignmentHelp review says:

    Cool blog! Thanks for sharing this material, never knew about Law of Cars. I only started to learn to code, so that was very useful for me.

  4. WaltonWilliam says:

    This is by and by related with the undertaking of sizes and courses of action to programming-tongue sorts. Another solidly related point is deforming. Calling conventions, sort portrayals, Buy custom Essays and name desolating are all piece of what is known as an application twofold interface.

  5. Stats Assignment help says:

    Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.

  6. 项目写作帮助 says:

    事情是非常开放和强烈清楚的解释问题。是真正的信息。你的网站是非常有益的。

  7. Write My Essay For Me says:

    Saved as a favorite, I love your web site!

  8. Write My College Paper For Me says:

    Aw, this was a really nice post. Spending some time and actual effort to generate a great article but what can I say… I put things off a whole lot and don't seem to get anything done.

  9. Star Wars Han Solo Jacket Buy Movie Jackets says:

    Car wellbeing is the examination and routine with regards to plan, development, hardware and direction to limit the event and outcomes of car accidents. Street activity wellbeing all the more comprehensively incorporates roadway outline.
    One of the main formal scholarly examinations into enhancing vehicle security was by Cornell Aeronautical Laboratory of Buffalo, New York. The primary finish of their broad report is the essential significance of safety belts and cushioned dashboards.

  10. Amanda says:

    That's some smart way of presenting the law of car with the implementation of coding. Help With Assignment Writing thinks of now new ways to present other laws.

  11. Evelyn Roger says:

    Actually I was looking for someone to teach me the law of car and finally here I have found it, pay someone to do my assignment but still some more laws I want to know so kindly please share it with me...

  12. Evie Walsh says:

    Before driving car its compulsory in the law of almost every country of the world to understand the law of car without knowing it coursework writing service uk, it can be dangerous for your life and also others..

  13. Julia Simmons says:

    Sometimes I wish I could make the right decisions in the right manner, then you need to make the correct things in order to get the best results. Assignment Hub - Economics Assignment

  14. Tyler Burn says:

    Everything in this World have some particular rules and guidelines to follow, but unfortunately we never accept that rules.. If you follow the rules so its your profit like if you follow law of car so who's benefit in that ?? Obviously its your's benefit... Custom Essay

  15. Ghost Rider Jacket says:

    Engine Vehicle Defects Law is a piece of shopper insurance law that arrangements with autos, trucks, cruisers, and different vehicles. Each vehicle producer and dealership warrants to its buyers that the autos they offer are protected to drive.

  16. lukenlow says:

    I like how you solved this problem, a very unusual and creative way of thinking 192.168.l.l

  17. Professional Essay Writers UK says:

    In Wild and Wonderful West Virginia, there may be a regulation regarding parking on private assets and even blocking off get right of entry to to a private drive. We are one of the Professional Essay Writers UK and can deliver quality work on time.

  18. https://casestudyaid.com says:

    This is great information for students. This article is very helpful i really like this blog thanks. I also have some information relevant for online dissertation help.

  19. Pay You to Do my Essay says:

    This is by using and with the aid of related to the venture of sizes and guides of action to programming-tongue types. Avenue pastime nicely being all the more comprehensively includes roadway outline. Pay You to Do my Essay The primary finish in their large record is the critical significance of safety belts and cushioned dashboards.

  20. Essay Help Pros says:

    Aw, this changed into a truly satisfactory submit. automobile wellbeing is the exam and routine with regards to plan, development, hardware, and the path to limit the event and results of automobile injuries. road pastime well-being all of the greater comprehensively contains roadway outline. things are very open and extremely clear rationalization of issues.

  21. TrueEssayHelp.co.uk says:

    Thank you for your submit. I suppose this publish sincerely will help college students. Your weblog is packed with unique excellent articles! this is by way of and via associated with the undertaking of sizes and courses of motion to programming-tongue sorts.

  22. Dissertation writers says:

    I really appreciate the way of your teaching regarding if else clauses are tremendous. As programmer and web developer I do recommend to all the young students keep trying to learn this clauses. Because it is so necessary for a programmer.

  23. Write My Essay says:

    Motor Vehicle Defects Law is a bit of customer protection law that courses of action with automobiles, trucks, cruisers, and distinctive vehicles. Every vehicle maker and dealership warrants to its purchasers that the cars they offer are secured to drive.

  24. Do my Assignment for me says:

    Indeed unquestionably it ought to be made necessary in each nation to offer chance to the lady with the goal that they can become famous.

  25. WritingEssay says:

    This is before long related to the endeavor of sizes and approaches to programming-tongue sorts. Another positively related point is disfiguring. Calling traditions, sort depictions, Buy custom Essays and name destroying are all bit of what is known as an application twofold interface.

  26. Assignment INC says:

    Really i appreciate the effort you made to share the knowledge. This is really a great stuff for sharing. Keep it up . Thanks for sharing.

  27. assignment writer says:

    Aw, this changed into a really acceptable submit. car prosperity is the exam and routine with respect to design, advancement, equipment, and the way to constrain the occasion and consequences of car wounds. street leisure activity prosperity the greater part of the more noteworthy exhaustively contains roadway diagram. things are exceptionally open and to a great degree clear defense of issues.

  28. Danny says:

    I’ve read the topic with great interest and definitely will stick your blog routinely for other great posts. Literature Review Paraphrasing Help Thank you for sharing this valuable and great article.

  29. Online Essay Help says:

    Your weblog is stuffed with special astounding articles! this is by method for and by means of related with the endeavor of sizes and courses of movement to programming-tongue sorts. This is extraordinary data for understudies. This article is exceptionally useful I extremely like this blog much obliged. I additionally have some data significant for online exposition help.

  30. Essay Service UK says:

    Much obliged to you for your submit. I assume this distribute truly will help understudies.

  31. Australia Assignment Help says:

    The leading assignment help UK firm offers state of the art services to its clients with a promise of delivering all the required work well within the deadline.

  32. EBook Writing Service says:

    by visiting this site I found cool stuff here keep it up.

  33. physicsmax6 says:

    Finance Assignment Help Online I personally like your post, you have shared good article. It will help me in great deal.

  34. Yousuf Media says:

    This is great information for students. This article is very helpful i really like this blog thanks. I also have some information relevant for online dissertation help.
    Social Media Marketing

  35. Halı Poşeti says:

    good article.

  36. Halı Yıkama Makinesi says:

    This is great information for students.

  37. Halı Sıkma Makinesi says:

    nice post

  38. C# programming help says:

    Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.

  39. Set Up Business in Dubai says:

    Hi buddy, your blog' s design is simple and clean and i like it. Your blog posts about Online writing Help are superb. Please keep them coming. Greets!

  40. Social Media Agency DHA says:

    Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have

  41. Toner Dolum says:
  42. thesis writing service says:

    I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    thesis Writing Service

  43. Mergers and Acquisitions consultant says:

    Well, it’s a nice one, I have been looking for. Thanks for sharing such informative stuff.Mergers and Acquisitions consultant

  44. Help With Marketing Projects says:

    This is really great work. Thank you for sharing such a useful information here in the blog.

  45. UK Dissertation Writing says:

    Aw, this changed into an extremely satisfactory submit. auto flourishing is the exam and routine as for plan, headway, hardware, and the best approach to oblige the event and outcomes of auto wounds. road recreation movement thriving most of the more essential comprehensively contains roadway graph. things are incredibly open and to an extraordinary degree clear guard of issues.

  46. Dissertation Helper Online says:

    Engine Vehicle Defects Law is a touch of client assurance law that strategies with cars, trucks, cruisers, and particular vehicles. Each vehicle creator and dealership warrants to its buyers that the autos they offer are secured to drive.

  47. UK Dissertation Help says:

    This is before long identified with the endeavor of sizes and blueprints to programming-tongue sorts. Another decidedly related point is misshaping. Calling traditions, sort depictions, Buy custom Dissertations and name destroying are all bit of what is known as an application twofold interface.

  48. Assignment Help Australia says:

    Amazing article thanks or sharing..

  49. assignment help says:

    Economicskey Provides quality Economics homework help for students.

  50. MYOB Project Help says:

    I loved the way you discuss the topic great work thanks for the share Your informative post.

  51. Psychology Assignment Help says:

    Thanx for sharing such useful post keep it up :)

  52. Online Mba Dissertation Writing Service says:

    Hi Buddy, Your Blog' S Design Is Simple And Clean And I Like It. Your Blog Posts About Online Dissertation Help Are Superb. Please Keep Them Coming. Greets!!

  53. Online Engineering Homework Help says:

    Amazing Article Thanks Or Sharing..

  54. Nursing Assignment Help says:

    The Leading Assignment Help UK Firm Offers State Of The Art Services To Its Clients With A Promise Of Delivering All The Required Work Well Within The Deadline.

  55. Help With OS Assignment says:

    This Is Great Information For Students. This Article Is Very Helpful I Really Like This Blog Thanks. I Also Have Some Information Relevant For Online Dissertation Help.

  56. Programming Assignment Help Assistance says:

    Science Channel’s Are Giving A Complete Knowledge To Its Viewers About Every Thing Students Write Done Dissertation On This Subjects And Show Its Importance.

  57. Case Solution says:

    amazing article thanks or sharing

  58. Cheap Assignment Help UK says:

    This is by way of and with the aid of related with the undertaking of sizes and publications of action to programming-tongue kinds. Another solidly associated point is deforming. Calling conventions, kind portrayals, Buy custom Essays and call desolating are all piece of what's known as an software twofold interface.

  59. Cheap Dissertation Writing UK says:

    This modified into an extremely excellent publish. car flourishing is the examination and habitual as for plan, headway, hardware, and the excellent approach to oblige the occasion and outcomes of vehicle wounds. street recreation movement thriving most of the greater crucial comprehensively includes roadway graph. matters are particularly open and to an top notch degree clear guard of problems

  60. Best Assignment Help UK says:

    It's a fine written article about Law of Car. And there are so many things that we can learn from this paragraph. Anyhow, Our team is experienced and energetic who provides essay writing with timely feedback, customer support and theft-free work. Our service is available for students who are having difficulty in writing essays and cannot write it before the deadline. We provide them unique assignment and we also provide unlimited revisions with continuous customer feedback support.

  61. Law Essay Writers UK says:

    As a long way as i can inform, the reality that driving with the interior mild on being illegal is a fable in North the united states. you can’t get a price tag particularly for driving with the indoors mild on. however, announcing that, it’s really not an excellent idea. Any form of light decreases driving force visibility at night time. indoors lighting fixtures create glare at the glass and the elevated light messes with the driving force’s night time vision.

  62. Sql Programming Assignment Help says:

    Really I Appreciate The Effort You Made To Share The Knowledge. This Is Really A Great Stuff For Sharing. Keep It Up . Thanks For Sharing.

Leave a Reply