Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Need help!!
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ulrich Nilsson  
View profile  
 More options Feb 18 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: "Ulrich Nilsson" <na95...@student.hgs.se>
Date: 1998/02/18
Subject: Need help!!

Hi

Does anyone have the solution to this problem:

Write a funktion that answers this question
(binary-to-decimal '(1 1 0 1)) --> 13


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martti Halminen  
View profile  
 More options Feb 18 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: Martti Halminen <m...@dpe.fi>
Date: 1998/02/18
Subject: Re: Need help!!

Ulrich Nilsson wrote:

> Hi

> Does anyone have the solution to this problem:

> Write a funktion that answers this question
> (binary-to-decimal '(1 1 0 1)) --> 13

Could you be more specific? What is your problem?

a) you don't know the algorithm you are trying to implement?
b) you don't know how to implement a known algorithm in Lisp?
c) your attempt does something odd that you don't understand?
d) you are too lazy to do your own homework?

If this is case c), post your attempt so that we can see what is going
wrong!
In case a), the trick is to iterate through the list backwards, raising
2 to increasing powers whenever the element isn't 0, and summing the
results.
Cases b and d require more effort from the originator. Should be doable
in 5 lines of code, depending on your style.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Hunter  
View profile  
 More options Feb 18 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: Larry Hunter <hun...@nlm.nih.gov>
Date: 1998/02/18
Subject: Re: Need help!!

Ulrich Nilsson asks:

 Does anyone have the solution to this problem:
 Write a funktion that answers this question
 (binary-to-decimal '(1 1 0 1)) --> 13

How about

 (defun binary-to-decimal (bits)
   (read-from-string (format nil "#b~{~d~}" bits)))

Hint: if you want turn the above in as homework, be prepared to explain what
it does.

--
Lawrence Hunter, PhD.
National Library of Medicine               phone: +1 (301) 496-9303
Bldg. 38A, 9th fl, MS-54                   fax:   +1 (301) 496-0673
Bethesda. MD 20894 USA                     email: hun...@nlm.nih.gov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Pazzani  
View profile  
 More options Feb 21 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: pazz...@ultra-pan.ics.uci.edu (Michael Pazzani)
Date: 1998/02/21
Subject: Re: Need help!!

In article <34eac7a9.0@alius>, Ulrich Nilsson <na95...@student.hgs.se> wrote:
>Hi

>Does anyone have the solution to this problem:

>Write a funktion that answers this question
>(binary-to-decimal '(1 1 0 1)) --> 13

I answered one of these once. A week later I got this e-mail.  Since
then I let students do their own homework and use this example in my
classes as a bad example of how to do homework.

Subject: easy money for you

    I'm looking for a lisp programmer to help me complete my project.
If you decide to accept, a mail-order-check will by made out to you and
mailed to your home
address.  You can reply with your home address if you decide to complete
this project.  I am willing to pay $60.00 for  fully functional codes.
Must have all of the code by september 28, 1997.

1. (use recursion for these, no iterative function)
  a).  Define a function nth-element that returns the nth element from
an arbitrary list. For example

(nth-element 2' (lisp (is really) ((fun))

       should return (is really).  assume correct expression, but
(nth-element 0 anylist) should return nil, also if number is larger than
length list, shoul return nil.

b). Define a function every-other-number that take a list and return a
list with every other number from the original list. for example:

(every-other-number '(this 5 is really 2 insane 3 41 28))
     should return this list (2 41).  If there is less than two number
in the list, return nil.  You can write more than one function (another
function) to call from
every-other-number that does part of the work for you.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neil Schemenauer  
View profile  
 More options Feb 21 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: nasch...@acs.ucalgary.ca (Neil Schemenauer)
Date: 1998/02/21
Subject: Re: Need help!!

On 21 Feb 1998 09:40:08 -0800, Michael Pazzani <pazz...@ultra-pan.ics.uci.edu> wrote:

>Subject: easy money for you

>    I'm looking for a lisp programmer to help me complete my project.
>If you decide to accept, a mail-order-check will by made out to you and
>mailed to your home
>address.  You can reply with your home address if you decide to complete
>this project.  I am willing to pay $60.00 for  fully functional codes.
>Must have all of the code by september 28, 1997.

(define (nth-element n l)
  (cond
   ((null? l) '())
   ((< n 1) '())
   ((eq? n 1) (car l))
   (else (nth-element (- n 1) (cdr l)))))

(define (every-other-number l)
  (define (filter p l)
    (cond
     ((null? l) '())
     ((p (car l)) (cons (car l) (filter p (cdr l))))
     (else (filter p (cdr l)))))

  (define (odd-elements l)
    (cond
     ((null? l) '())
     ((null? (cdr l)) l)
     (else (cons (car l) (odd-elements (cddr l))))))

  (define (even-elements l)
    (cond
     ((null? l) '())
     (else (odd-elements (cdr l)))))

  (even-elements (filter number? l)))

That would have been easy money.  Too bad I'm too late. :)  Why
the hell do people pay money to go to school and refuse to learn
anything?

        Neil


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Feb 22 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <cle...@naggum.no>
Date: 1998/02/22
Subject: Re: Need help!!

* Neil Schemenauer
| That would have been easy money.  Too bad I'm too late. :)  Why the hell
| do people pay money to go to school and refuse to learn anything?

  so that they can bring their diplomas and get jobs where people who also
  refuse to learn anything (their managers) pay _them_ lots of money, for a
  change.  hey, it keeps a lot of the population happy.  can't be wrong.

#:Erik
--
  God grant me serenity to accept the code I cannot change,
  courage to change the code I can, and wisdom to know the difference.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David D. Smith  
View profile  
 More options Mar 4 1998, 3:00 am
Newsgroups: comp.lang.lisp
From: d...@flavors.com (David D. Smith)
Date: 1998/03/04
Subject: Re: Need help!!

In article <34eac7a9.0@alius>, "Ulrich Nilsson" <na95...@student.hgs.se> wrote:
> Hi

> Does anyone have the solution to this problem:

> Write a funktion that answers this question
> (binary-to-decimal '(1 1 0 1)) --> 13

(defun binary-to-decimal (bits)
  (reduce #'(lambda (a b) (logior (ash a 1) b)) bits :initial-value 0))

? (binary-to-decimal '(1 1 0 1))
13
?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »