I highly, highly recommend the SICP (also available online). The SICP uses Scheme. But it doesn't just teach the language. It teaches you how to program, and think, functionally. Things like the different types of recursion (tree-recursive, vs linear recursive, vs iterative [did you know you can write a recursive program that executes iteratively‽]). Highly recommend it. It will help you learn to think functionally to a much greater degree than an ordinary Scheme tutorial. FYI I'm kind of in the same boat. I was taught OO and Imperative programming, and I've been trying to make the vertical ascent to FP. It's hard to find the time.
Thank you very much for this suggestion. I have been wanting to try functional programming for a long time, after seeing so many inscrutable and concise solutions on Project Euler. I never managed to get far with Haskell, though. In addition to the web version you linked to, Chris Krycho has created a nicely-formatted Kindle version. I am 4% through it and managed to write my first Scheme code for Exercise 1.3: "Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers." delta, how's your progress coming?
I am using a handy online interpreter. (define (square a) ( * a a))
(define (sumofsquares a b) (+ (square a) (square b)))
(define (<= a b) (or (< a b) (= a b)) )
(define (sosbig2 a b c)
(cond
( (and (<= a b) (<= a c)) (sumofsquares b c))
( (and (<= b a) (<= b c)) (sumofsquares a c))
( (and (<= c a) (<= c b)) (sumofsquares a b))))
Well, I decided I didn't like Scheme's syntax + there aren't many frameworks & libraries that support it. I'm learning C now, and I like it a lot more. The main reason I'm learning C is that I plan to use OpenWRT for a science fair. Your code above is pretty damn beautiful, though. I wrote a program yesterday because my sister wanted a program related to flowers. (✿◠‿◠)
#include <stdio.h>
main()
{
int rose_amt = 12;
int daisy_amt = 7;
int tulip_amt = 23;
int sunflower_amt = 42;
int rose;
int daisy;
int tulip;
int sunflower;
int exit_value;
printf("This program will calculate the grand total number of days\nit will take for four different kinds of flowers to grow.\n\n");
printf("Roses take %d days to grow.\n", rose_amt);
printf("Daisies take %d days to grow.\n", daisy_amt);
printf("Tulips take %d days to grow.\n", tulip_amt);
printf("Sunflowers take %d days to grow.\n", sunflower_amt);
printf("\nHow many roses do you wish to plant?\n");
scanf(" %d", &rose );
printf("How many daisies do you wish to plant?\n");
scanf(" %d", &daisy);
printf("How many tulips do you wish to plant?\n");
scanf(" %d", &tulip);
printf("How many sunflowers do you wish to plant?\n");
scanf(" %d", &sunflower);
printf("\nIt will take a grand total of %d days for all the flowers to grow.\n", rose*rose_amt+daisy*daisy_amt+tulip*tulip_amt+sunflower*sunflower_amt);
printf("\nWould you like to exit?\n");
scanf("%d");
return 0;
}
Thanks for the resource & information! I definitely need to learn how to program before attempting to learn. Many people don't understand the difference; one of my friends learned the complete syntax of Python, then realized he didn't know how to do anything with it (thanks, Codecademy). By the way, Scheme is my first venture into programming outside of HTML+CSS and looking at Python a few years ago. We'll see how it goes.