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
the "loop" macro
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
  6 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
 
WJ  
View profile  
 More options Mar 15 2012, 9:21 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 15 Mar 2012 13:21:20 GMT
Local: Thurs, Mar 15 2012 9:21 am
Subject: Re: the "loop" macro

Clojure:

user=> (keep #(if (odd? %) (* % %)) [1 2 3 4])
(1 9)

> The ability in loop to do even complex things like:

>  (loop for x in '(1 2 3 4 5 6 7)
>     when (evenp x)
>      collect x into evens
>     else
>      collect x into odds
>     finally
>      (return (values evens odds)))
>  => (2 4 6), (1 3 5 7)

> is considerably easier and clearer than some other alternatives.

That doesn't look very Lispy to me, Kent.

Clojure:

user=> (replace (group-by even? (range 1 8)) [true false])
[[2 4 6] [1 3 5 7]]

> Also, being able to vary the collection is handy.  Consider:

> (loop for x in '(a b (c d) e f)
>        when (atom x)
>         collect x
>        else
>         append x)
>  => (A B C D E F)

That doesn't look very Lispy to me, Kent.

Clojure:

user=> (flatten '(a b (c d) e f))
(a b c d e f)


 
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.
WJ  
View profile  
 More options Mar 15 2012, 9:36 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 15 Mar 2012 13:36:52 GMT
Local: Thurs, Mar 15 2012 9:36 am
Subject: Re: the "loop" macro

That doesn't look very Lispy to me, Kent.

Clojure:

user=> (max-key count "ah" "sleipnir" "see" "zebra")
"sleipnir"
user=> (apply max-key count ["ah" "sleipnir" "see" "zebra"])
"sleipnir"


 
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.
WJ  
View profile  
 More options Mar 15 2012, 9:54 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 15 Mar 2012 13:54:15 GMT
Local: Thurs, Mar 15 2012 9:54 am
Subject: Re: the "loop" macro

MatzLisp (Ruby):

["ah","sleipnir","see","zebra"].max_by{|s| s.size}
    ==>"sleipnir"


 
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.
WJ  
View profile  
 More options Mar 31 2012, 4:46 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 31 Mar 2012 08:46:53 GMT
Local: Sat, Mar 31 2012 4:46 am
Subject: Re: the "loop" macro

(def f number?)
(defn g [n] (* n n))

(reduce #(if (f %2)(cons (g %2) %1) %1) '() '(a 2 c 4))
 ==> (16 4)


 
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.
WJ  
View profile  
 More options May 3 2012, 5:04 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 3 May 2012 09:04:31 GMT
Local: Thurs, May 3 2012 5:04 am
Subject: Re: the "loop" macro

Racket:

(filter-map (lambda(n) (and (odd? n) (* n n))) '[1 2 3 4])
 => '(1 9)

Racket:

(partition even? '[1 2 3 4 5 6 7])
 => '(2 4 6)
    '(1 3 5 7)

Racket:

(flatten '(a b (c d) e f))
 => '(a b c d e f)


 
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.
WJ  
View profile  
 More options Apr 10, 4:43 pm
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 10 Apr 2013 20:43:03 GMT
Local: Wed, Apr 10 2013 4:43 pm
Subject: Re: the "loop" macro

Instead of CL, tCL.

namespace path {::tcl::mathop ::tcl::mathfunc}

lmap n {2 3 4 5} {if [& 1 $n] {** $n 2} {continue}}
 ==>
9 25


 
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 »