[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: print command



theocrite@free.fr writes:

> Quoting Bijan Soleymani <bijan@psq.com>:
>
>> In perl you could do:
>> perl -e 'for(1..80){print "*";}print "\n";'
>
> Can you just explain how to use this for ? It seems far away the ones I know
> (C,C++,basic,Java,php,etc.)

That invocation happens to do the perlish thing of setting $_ to each
of 1, 2, 3, ..., 80 in turn.  Perl also supports the C-like for, but
that's not what you'd use in a one-liner.

For gratuitousness, in a completely different style:

(define (star-string n)
  (define (star-helper n s)
    (if (= n 0) s
      (star-helper (- n 1) (concat "*" s))))
  (star-helper n ""))

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: