View unanswered posts | View active topics It is currently Sun Sep 05, 2010 2:13 am



Post new topic Reply to topic  [ 3 posts ] 
Idea for MAP function 
Author Message

Joined: Wed Apr 07, 2010 12:18 am
Posts: 9
Post Idea for MAP function
I was thinking of a new form of the MAP function that would be useful. I would like to have a form of it where you could write (map func list true) where instead of a second list you have a truth flg to denote the new form. In this arrangement what happens is that func is mapped onto list. The values of the mappings are compared to each other, if they are all equal then the value is returned else nil is. This doesn't break the current syntax and adds another useful feature but maybe others disagree.


Fri Jul 23, 2010 4:38 am
Profile E-mail

Joined: Tue Nov 29, 2005 8:28 pm
Posts: 1691
Location: latiitude 50N longitude 3W
Post Re: Idea for MAP function
Nice idea. A lot of existing functions append an optional function (func-compare) at the end. Not sure if that's useful here - but are there more general purpose applications than just a "is everything equal?" test?


Sat Jul 24, 2010 6:06 pm
Profile WWW

Joined: Mon Feb 08, 2010 8:47 am
Posts: 47
Post Re: Idea for MAP function
I thought some functions.

Code:
(define (map+ func lst bool)
  (if bool
      (apply = (map func lst))
    (map func lst))
)

(define (map-compare func lst value)
  (apply = (cons value (map func lst)))
)

(define (map-predicate func lst bool)
  (if bool
      (for-all func lst)
    (map func lst))
)


Which is corresponding ? or another function ?


Sat Jul 24, 2010 11:39 pm
Profile E-mail
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.