Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › What Programming Language Should I Learn?
New Posts  All Forums:Forum Nav:

What Programming Language Should I Learn? - Page 3

post #21 of 22
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!
Edited by The Bartender Paradox - 7/2/08 at 2:40pm
½
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD A64 3500+ Winchester DFI nF4 SLi-DR EVGA 7800GT OCZ 4000VX 
Hard DriveOptical DriveOSMonitor
Maxtor 300Gb 16Mb Buffer Spinney one XP Pro SOYO LCD 
KeyboardPowerCaseMouse
Broken Somewhat OCZ PowerStream 520W None Old 
Mouse Pad
Pad? AHAAHAHAH 
  hide details  
Reply
½
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD A64 3500+ Winchester DFI nF4 SLi-DR EVGA 7800GT OCZ 4000VX 
Hard DriveOptical DriveOSMonitor
Maxtor 300Gb 16Mb Buffer Spinney one XP Pro SOYO LCD 
KeyboardPowerCaseMouse
Broken Somewhat OCZ PowerStream 520W None Old 
Mouse Pad
Pad? AHAAHAHAH 
  hide details  
Reply
post #22 of 22
Quote:
Originally Posted by DuckieHo View Post
Cobol!
sadist!
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
RAWR
(13 items)
 
Home Server
(11 items)
 
 
CPUMotherboardGraphicsRAM
i7-4790k msi z97 gaming 7 gtx 760 4gb 32GB GSkill  
Hard DriveHard DriveCoolingOS
Kingston HyperX 3K 120GB SSD Hitachi 2TB Cooler Master Hyper 212+ Windows 8.1 Pro 
MonitorKeyboardPowerCase
Vizio M492-b2 Logitech Wireless  Corsair HX620 NZXT Phantom White 
Mouse
Logitech Wireless 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › What Programming Language Should I Learn?