Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

The idea of ``squaring''

Name: Anonymous 2012-07-16 4:40

How is the idea of ``squaring'' expressed?

Name: Anonymous 2012-07-16 5:07

SQUARE MY ANUS

Name: Anonymous 2012-07-16 6:11

(defclass multipliable-list () ((xs :type 'list :initarg :xs)))
(defgeneric get-multipliable-list-product (x))
(defmethod get-multipliable-list-product ((x multipliable-list))
  (reduce #'* (slot-value x 'xs)))

(defclass i-squarable () ((x :type number :initarg :x)))
(defclass squarable-number (i-squarable) ())

(defgeneric make-squarable-number-from-number (x))
(defmethod make-squarable-number-from-number ((x number))
  (make-instance 'squarable-number :x x))

(defgeneric make-multipliable-list-from-squarable (x))
(defmethod make-multipliable-list-from-squarable ((x i-squarable))
  (let ((num (slot-value x 'x)))
    (make-instance 'multipliable-list :xs (list num num))))

(defun square (x)
  (get-multipliable-list-product (make-multipliable-list-from-squarable (make-squarable-number-from-number x))))

Name: Anonymous 2012-07-16 13:59

>>3
Stay the fuck away from my codebase.

Name: Anonymous 2012-07-16 14:04

*quadrangling

Name: Anonymous 2012-07-16 16:57

def square(num): return num*num

Name: Anonymous 2012-07-16 17:38

(lambda (x) (* x x))

Name: Anonymous 2012-07-16 19:06

(INT x)INT: x ** 2

Name: Anonymous 2012-07-16 19:29

square x = x * x

Name: Anonymous 2012-07-16 19:54

#!/bin/bash
echo "what is the number you wish to have squared?"
read x
let xsquared=x*x
echo "$x squared equals $xsquared"

or something like that

Name: Anonymous 2012-07-16 19:56

#(* % %)

Name: Anonymous 2012-07-16 21:17

(<$>)(=<<)(<$>(*))($)id
VALID HASKAL CODE

Name: Anonymous 2012-07-16 22:12

>>5
cokstrangling

Name: Anonymous 2012-07-17 0:12

((sum<$>inits[1,3..])!!)

Name: Anonymous 2012-07-17 19:29

>>12
WTF does that even do? I know it squares a number, but how?

Name: Anonymous 2012-07-18 0:29

>>15
Really, /prog/, is this how shit you've become? Really?

(<$>)(=<<)(<$>(*))($)id
fmap (=<<) (fmap (*)) id id
((=<<) . ((*) .)) id id
((=<<) . (\g x -> (*) (g x))) id id
(\y -> (=<<) ((\g x -> (*) (g x)) y)) id id
(=<<) ((\g x -> (*) (g x)) id) id
(=<<) (\x -> (*) (id x)) id
(=<<) (\x -> (* x)) id
(=<<) (*) id
(*) =<< id
\z -> (* z) (id z)
\z -> z * z

Name: Anonymous 2012-07-18 0:53

>>16
Haskell on Homosexuals.

Name: Anonymous 2012-07-18 7:23

Haskell on Haemorrhoids.

Name: Anonymous 2012-07-18 8:09


;;; This is all we need:
(define zero (lambda (f) (lambda (x) x)))
(define add-1 (lambda (n) (lambda (f) (lambda (x) (f ((n f) x))))))

;;; We define ``two''
(define two (lambda (f) (lambda (x) (f (f x))))) ; or (define two (add-1 (add-1 zero)))

;;; ``square'' is simply:
(define square (lambda (n) (two n)))

;;; Some shit only useful for mortals:

(define (church->int n)
  ((n add1) 0))

(define int->church
  (lambda (n)
    (if (zero? n)
        zero
        (add-1 (int->church (- n 1))))))

;;; Now let's say you want 14^2
(define fourteen (int->church 14))
(church->int (square fourteen)) ;yields 196

Name: Anonymous 2012-07-18 9:43

>>19
jesus fucking christ

Name: Anonymous 2012-07-18 11:10

>>19
I spent one hour trying to understand how it worked before realising add1 in chuch->int was not the Church add-1 but a standard function. In effect I achieved a very disappointing Satori.

Name: Anonymous 2012-07-18 11:43

>>21
I am truly sorry. It is indeed a very bad choice of a name and should have been inc.

Don't change these.
Name: Email:
Entire Thread Thread List