Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 07-02-08   #21 (permalink)
Off By 340 Undecillion
 
The Bartender Paradox's Avatar
 
amd nvidia

Join Date: Oct 2004
Location: Portland, Oregon
Posts: 2,291

Rep: 293 The Bartender Paradox is a proven memberThe Bartender Paradox is a proven memberThe Bartender Paradox is a proven member
Unique Rep: 224
Hardware Reviews: 1
Trader Rating: 3
Default

Quote:
Originally Posted by Raptors06 View Post
I'm in agreement - that does look simple and intuitive. Will have to look into that.
And the best part is it can become really powerful fairly quickly. Lets go back to the sum function. Now in mathematics there is Sigma which serves to sum things:


It will take only a little work to get our sum function to work with this very general and useful tool. Below is a function that is a little more general than even mathematical definition of sigma. Sigma takes as its arguments a function to apply to an input, a stopping condition, a way to get to the next sum value, and the starting data m. One of the really cool things in Scheme is that a function can be passed exactly like any other variable.

Code:
(define (sigma function next condition m)
    (if (condition m)
         0
         (+ (function m)
            (sigma function condition next (next m)))))
Now to get the sum for our average function we just plug in arguments to sigma:

(sigma car cdr null? b)

Now how about a sum of squares from 1 to 49? like 1^2 +2^2 + 3^2 + 4^2 ...
all you need is:

Code:
(sigma square add1 lessthan50 1)

(define (add1 x) (+ x 1))

(define (lessthan50 y) (> 50 y))
Super simple!
__________________

A rocket powered land shark attached to a giant freakin' laser beam.
Congratulations! You have found the secret text! You get a cookie.

System: My System
CPU
AMD A64 3500+ Winchester
Motherboard
DFI nF4 SLi-DR
Memory
OCZ 4000VX
Graphics Card
EVGA 7800GT
Hard Drive
Maxtor 300Gb 16Mb Buffer
Sound Card
computers make sounds?
Power Supply
OCZ PowerStream 520W
Case
None
CPU cooling
Big
GPU cooling
Bigger
OS
XP Pro
Monitor
SOYO LCD

Last edited by The Bartender Paradox : 07-02-08 at 05:40 PM.
The Bartender Paradox is offline Overclocked Account The Bartender Paradox's Gallery   Reply With Quote
Old 07-08-08   #22 (permalink)
Mmmm! Toast!
 
hometoast's Avatar
 
intel nvidia

Join Date: Sep 2007
Location: Pennsylvania
Posts: 1,062

Rep: 85 hometoast is acknowledged by some
Unique Rep: 69
Folding Team Rank: 377
Trader Rating: 8
Default

Quote:
Originally Posted by DuckieHo View Post
Cobol!
sadist!
__________________
Rocket 3 down-payment fund: [|||||||||] $6k
e6750 @ 3.2 Ghz (400x8) - 7k ppd GPU+SMP

System: Muh Box
CPU
E6750 @ 3.2Ghz
Motherboard
DFI Blood Iron
Memory
4x1G GSkill HZs @960
Graphics Card
eVGA 8800GT 512 @675/950
Hard Drive
2xWD 320 AAKS Raid0 + 74G Raptor
Sound Card
on-board. (linux!=xfi)
Power Supply
CM Extreme Power 650W
Case
CM Centurion 5
CPU cooling
AC Freezer 7
OS
Vista Ultimate 64
Monitor
Samsung 204BW
hometoast is offline I fold for Overclock.net Overclocked Account   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 01:48 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.13014 seconds with 9 queries