Logo

Programming-Idioms

History of Idiom 3 > diff from v12 to v13

Edit summary for version 13 by :

Version 12

2015-10-27, 03:05:01

Version 13

2015-10-29, 14:05:11

Idiom #3 Create a procedure

Like a function which doesn't return any value, thus has only side effects (e.g. Print to standard output)

Idiom #3 Create a procedure

Like a function which doesn't return any value, thus has only side effects (e.g. Print to standard output)

Code
fn finish(name : &str) {
    println!("My job here is done. Goodbye {}", name);
}
Code
fn finish(name : &str) {
    println!("My job here is done. Goodbye {}", name);
}
Comments bubble
The actual return type is Unit, typed '()' and can be ommited from function signature.
Comments bubble
The actual return type is Unit, typed '()' and can be ommited from function signature.
Demo URL
http://is.gd/KqExyU
Demo URL
http://is.gd/KqExyU
Code
(define (finish name)
    (begin
        (display "My job here is done. Goodbye ")
        (display name)
        (newline)))
Code
(define (finish name)
    (begin
        (display "My job here is done. Goodbye ")
        (display name)
        (newline)))
Comments bubble
This is a short syntax for a lambda definition.
Comments bubble
This is a short syntax for a lambda definition.
Demo URL
http://repl.it/SII
Demo URL
http://repl.it/SII
Code
def finish( name )
	p "My job here is done. Goodbye #{name}"
end
Code
def finish( name )
	p "My job here is done. Goodbye #{name}"
end
Comments bubble
It is faster than p "My job here is done. Goodbye " + name.

Comments bubble
It is faster than p "My job here is done. Goodbye " + name.

Imports
import "fmt"
Imports
import "fmt"
Code
func finish(name string) {
  fmt.Println("My job here is done. Good bye " + name)
}
Code
func finish(name string) {
  fmt.Println("My job here is done. Good bye " + name)
}
Demo URL
http://play.golang.org/p/NSbp6jceZH
Demo URL
http://play.golang.org/p/NSbp6jceZH
Code
def finish(name):
	print "My job here is done. Goodbye " + name
Code
def finish(name):
	print "My job here is done. Goodbye " + name
Code
void finish(String name){
  System.out.println("My job here is done. Goodbye " + name);
}
Code
void finish(String name){
  System.out.println("My job here is done. Goodbye " + name);
}