Name: Anonymous 2011-02-12 6:10
Fibonacci in Perl6.
Can your toy language do this?
my @fib := (0, 1, *+* ... *);Can your toy language do this?
my @fib := (0, 1, *+* ... *);(define (Π f n m)
(let ((x (future
(lambda ()
(let/ec k
(do ((x n (+ x 2))
(r 1 (* r (f x))))
((> x m) (k r)))))))
(y (let/ec k
(do ((x (add1 n) (+ x 2))
(r 1 (* r (f x))))
((> x m) (k r))))))
(* y (touch x))))
(define (fact x)
(Π values 1 x))
(define (Π f n m (c (processor-count)))
(let* ((t (lambda ()
(let/ec k
(do ((x n (+ x c))
(r 1 (* r (f x))))
((> x m) (k r))))))
(xs (do ((x (sub1 c) (sub1 x))
(xs '() (cons (future t) xs)))
((zero? x) xs)))
(x (t)))
(map (compose (curry apply *) touch) (cons x xs))))
(define (Π f n m (c (processor-count)))
(let* ((t (lambda (a)
(lambda ()
(let/ec k
(do ((x (+ n a) (+ x c))
(r 1 (* r (f x))))
((> x m) (k r)))))))
(xs (do ((x (sub1 c) (sub1 x))
(xs '() (cons (future (t x)) xs)))
((zero? x) xs)))
(x ((t 0))))
(foldr * x (map touch xs))))
my@d=((<♦ ♠ ♥ ♣>X~(2..10,<J Q K A>))Z=>[2..9,10 xx 4,1|11]).pick(*);my@p=[],[];sub a{@^c.push(@d.pop)};sub b{[+]@^c».value};for@p {.&a;.&a;say '-'x 33;loop {if .&b!<22 {"{$_».key} > 21".say;last};say .&b,"\n{$_».key}";last if prompt('(h)it (s)it? ')~~'s';.&a}};say 'Winner:'~ %([max]@p.grep({.&b<22})).keys
#include <stdio.h>
int main(void) {
struct num{ unsigned int a:3, b:3, c:2; } n = {0};
unsigned char *c = &n;
do do printf("%hhu\n", *c);
while(!(n.a-- && !++n.b));
while(++n.c);
return 0;
}
>,>,>++++++++[-<------<------>>]++++++++++[-<<[-<+>>+<]<[->+<]>
>>]<[-<<+>>]<[-]>>>>>>>>>>>>+<<<<<<<<<<<<<[->>+>+>+>+[->>>>[->>
>>>>>>+<<<<<<<<]>>>>[-<<<<+>>>>>>>>+<<<<]>>>>[-<<<<+>>>>]<<<<<<
<<<<<<<]>>>>>>>>>>>>>>+>+>+[-<<<<<[->>>>>+<<<<<]>[->>>>>+<<<<<]
>>>>>>+[<[->>+>+<<<]>>[-<<+>>]+>>>>[-]+++++++++<<<<[>[->+>+<<]+
>[<->[-]]<[-<[-]>]>>-[-<<+>>]>[->+>+<<]+>[<->[-]]<[-<<<<[-]>>>>
]>>-[-<<+>>]<<<<<<]+>+[[-]<-<<———-<+>>>>]<[[-]<[-]>]<]<<[-<<<<<
+>>>>>]>[-<<<<<+>>>>>]<<]<<<<<<<<<<<<<<]>>>>>[-]+++++++++++++++
+[->+++>+++>+++>+++<<<<]>.>.>.>...., which just saves a little typing. It's in :=, which saves a lot of typing.
public class TakeItEasy
{
public static void main(String []args)
{
System.out.println("");
}
}