Southperry.net
Count to 10 - Printable Version

+- Southperry.net (https://www.southperry.net)
+-- Forum: Social (https://www.southperry.net/forumdisplay.php?fid=14)
+--- Forum: Rubik's Cube (https://www.southperry.net/forumdisplay.php?fid=58)
+--- Thread: Count to 10 (/showthread.php?tid=42181)

Pages: 1 2


Count to 10 - GMSInfighter - 2011-05-23

Can anyone point me to a pretty decent guide on C++ and Python?

Off-topic, I know.. But I've got nothing better to do than touch up on it.


Count to 10 - Erebus - 2011-05-23

NVM didn' t read restrictions


Count to 10 - shouri - 2011-05-23

It specifically stated that you weren't allowed to type up the numbers 1-10 and just print that out.


Count to 10 - Luacake - 2011-05-23

More fun. http://shakespearelang.sourceforge.net/

 SPL

Not entirely sure it works as I don't have the converter and can't compile it myself...


Count to 10 - Loose - 2011-05-23

Code:
public class countTen
{
    public static void main(String[] args) {
        System.out.println("1, 2, 3, 4, 5, 6, 7, 8, 9, 10");
    }
}

 ActionScript using Flixel Engine



Count to 10 - Hazzy - 2011-05-23

Eosian Wrote:You stated elegence was the target, short and succinct.
What did you expect?

I never said elegance and creativity were mutually exclusive.


Count to 10 - OB3LISK - 2011-05-23

I suck then LOL.


Count to 10 - Nikkey - 2011-05-23

Arc (lisp dialect)
Code:
(for (i 1 10)
  (prn i))

I don't think it gets any easier. Maybe tail-recursion is more elegant?

Arc again
Code:
(def accum (acc)
  (prn acc)
  (if (< acc 10)
    (accum (1+ acc))))
    
(accum 1)

(Quick and dirty CLISP)
Code:
(loop for i from 1 to 10
  do (print i))

Orrr, since you'll usually have some sort of range-function defined
Code:
(defun range (a b)
  (loop for i from a to b
    collect i))
    
(format t "~{~D~%~}"
  (range 1 10))



Count to 10 - Shidoshi - 2011-05-23

Those lisp code examples make me understand that XKDC comic.
[Image: lisp_cycles.png]


Count to 10 - Luacake - 2011-05-24

Devil's Sunrise Wrote:Arc (lisp dialect)

Shidoshi Wrote:Those lisp code examples make me understand that XKDC comic.

http://ycombinator.com/arc/tut.txt

Oh my god.

I just read 1/3 of the way through and the lack of fluff already kind of amazes me. It's beautiful.


Count to 10 - Stereo - 2011-05-24

shouri Wrote:R
Code:
seq(1:10)

You only need to write '1:10' and it'll output them. Probably works in MATLAB too, though I don't have a copy.

If you want it to actually print them,
Code:
cat(1:10)
Will give you the output you want. Or, to match with the other loops,
Code:
cat(1:10,sep="\n")
Will put each on a new line.


Getting into stupider methods of doing it in R...
Code:
y <- c(1:10,0)
x <- 1:11
c <- (lm(y ~ poly(x,10,raw=TRUE)))$coefficients
f <- function(x) {
  return(c[1] + c[2]*x + c[3]*x^2 + c[4]*x^3 + c[5]*x^4
         + c[6]*x^5 + c[7]*x^6 + c[8]*x^7 + c[9]*x^8
         + c[10]*x^9 + c[11]*x^10)
}
f(1:10)
Fit a degree 10 polynomial to the sequence, plus 0. Create a function that evaluates that polynomial. Then calculate the values of that function at the points 1 to 10.