A Failure To Understand lazy-seq

2017-09-04 Thread mrwizard82d1
I'm trying to understand infinite sequences.

Wikipedia defines an implementation of the Fibonacci sequence as:

(def fibs (cons 0 (cons 1 (lazy-seq (map +' fibs (rest fibs))

However, when I wrote fibs in the repl as:

(def fibs (lazy-seq (cons 0 (cons 1 (map +' fibs (rest fibs))

executing (first fibs) produces a StackOverflow exception.

What is the reason that the second, incorrect definition throws a 
StackOverflow exception, but the first generates an infinite sequence?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure-CLR, CLASSPATH, clojure.load.path and Cygwin

2011-08-17 Thread mrwizard82d1
Thanks, Stephen.

Although I was aware of the env command, I had never needed it before.
I believe this solution will allow me to solve my immediate problem
(running Clojure-CLR with the classpath configured for a specific
project as I do in Java).

On Aug 17, 6:31 am, Stephen Compall stephen.comp...@gmail.com wrote:
 The . limitation is in bash vars only; they work fine as environment vars:

 $ clojure.load.path=whatever command
 Some error message I forget
 $ env clojure.load.path=whatever command
 Sets env var while running command

 You should already have env installed.  It's pretty useful if you like 
 working in sh; check out its manpage for more.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure-CLR, CLASSPATH, clojure.load.path and Cygwin

2011-08-17 Thread mrwizard82d1
Alan,

Thanks for fighting for *nix folks.

Although I can solve my singular problem using the solution posted by
Stephen, you reminded me of another reason I wrote my question as I
did.

Although I'm not involved, I understand that people continue to work
on the Mono project which provides the CLR for *nix environments. I
know that the IronPython community has worked to ensure that its
products work not only on a native Windows environment, but also in a
Mono environment.

On Aug 17, 8:48 am, Alan D. Salewski salew...@att.net wrote:
 On Tue, Aug 16, 2011 at 01:23:23PM -0400, Ken Wesson spake thus:









  On Tue, Aug 16, 2011 at 1:20 AM, Alan D. Salewski salew...@att.net wrote:
   On Tue, Aug 16, 2011 at 12:34:39AM -0400, Ken Wesson spake thus:
   On Mon, Aug 15, 2011 at 11:13 AM, mrwizard82d1 mrwizard8...@gmail.com 
   wrote:
I understand that the 1.3 beta plans to add an environment variable
named clojure.load.path to provide a CLASSPATH mechanism for Clojure
on the CLR.

Although I use Windows, I have installed cygwin because I prefer the
Unix tool set to that provided by Windows. Although a Windows console
allows one to set environment variables like clojure.load.path, the
bash shell does not.

   Are you sure there isn't some form of quoting or escaping that will
   make that name acceptable to bash?

   Identifiers in bash may contain only alphanumeric characters and
   underscores, and must start with an alphabetic character or underscore;
   there's no way to get around that with escaping or quoting.

  Pardon me, but that seems to be missing the point.

 Your point, to which I was responding, was that there might be some
 form of quoting or esacaping that would make the environment variable
 with the name 'clojure.load.path' acceptable to bash. My point,
 offered only to help avoid wasting time going down that path of
 investigation, is that there is not, with the implied reason that
 environment variable manipulation in bash can only be performed on
 environment variables that are valid bash identifiers.

 Based on your addions below, it is now clear that you are only talking
 about the ability of bash to pass through to its children an
 environment variable that it was provided by it's parent process. I
 would describe that level of capability as tolerance, not acceptance.

 It is the default behavior of bash 4.1 and newer for environment
 variables received from the parent process that are not valid bash
 identifiers: they are passed through to the environment of child
 processes, despite the fact that they have not been (and cannot be)
 explicitly exported. Tolerance.

 Acceptance, in my view, would include the ability to query the current
 environment for the value, and the ability to manipulate the value seen
 by subprocesses using the common approach on a per-invocation basis:

     $ SOMEVAR=SOMEVAL /path/to/command [arg[ arg...]]

 without resorting to 'env' or other hacks, which is not the case:

     $ ALJUNK_CRAP=junk /bin/bash -c set | grep ALJU
     ALJUNK_CRAP=junk

     $ ALJUNK.CRAP=junk /bin/bash -c set | grep ALJU
     bash: ALJUNK.CRAP=junk: command not found

     $ /usr/bin/env -- ALJUNK_CRAP1=junk1 ALJUNK.CRAP2=junk2 /bin/bash -c env 
 | grep ALJU
     ALJUNK.CRAP2=junk2
     ALJUNK_CRAP1=junk1

     $ /usr/bin/env -- ALJUNK_CRAP1=junk1 ALJUNK.CRAP2=junk2 /bin/bash -c set 
 | grep ALJU
     ALJUNK_CRAP1=junk1

  You don't need a
  bash-language variable named clojure.load.path, you just need to set
  a Windows environment variable named clojure.load.path, and the
  rules for what characters are allowed in the names of Windows
  environment variables will still be those set by Windows, which
  apparently permit periods. As far as your bash script is concerned,
  clojure.load.path probably needn't be anything more than an opaque
  string passed to the host operating system via a call of some kind --
  though that string could conceivably require quoting or escaping where
  it's embedded as a literal in the script.

  If bash has its own environment variable system, then that could be
  confusing you,

 The only confusion is that you and I read differently mrwizard82d1's
 question, which set the tone for the thread:

     How do we plan to support an alternative name that can be used by
      people running Clojure-CLR from within cygwin?

 You approached the question from the perspective of one just wanting to
 launch Clojure-CLR with a 'clojure.class.path' value inherited from the
 host OS, however that can be made to work.

 I approached the question from the perspective of one wanting to invoke
 Clojure-CLR with the ability to manipulate the value of
 'clojure.class.path' on-the-fly in a way that is common and natural
 for *nix folks.

 The answer at the moment (as with many things related to cygwin) seems
 to be that basic usage will just work; other usage will be possible
 but more cumbersome.

 -Al

 %!PS Unix and Linux allow periods

Clojure-CLR, CLASSPATH, clojure.load.path and Cygwin

2011-08-15 Thread mrwizard82d1
I understand that the 1.3 beta plans to add an environment variable
named clojure.load.path to provide a CLASSPATH mechanism for Clojure
on the CLR.

Although I use Windows, I have installed cygwin because I prefer the
Unix tool set to that provided by Windows. Although a Windows console
allows one to set environment variables like clojure.load.path, the
bash shell does not.

How do we plan to support an alternative name that can be used by
people running Clojure-CLR from within cygwin?

Thanks.

Have a great day!

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en