KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm primarily a C++ (thus an OO/imperative) programmer and I find it quite bizarre that you can only have one statement per evaluation in a conditional statement such as an if-statement in Scheme, a functional language. For example: (let ((arg1 0) (arg2 1)) (if (> arg1 arg2) arg1 arg2))) Erroneous example: (let ((arg1 0) (arg2 1)) (if (> arg1 arg2) (arg1 (display "cool")) (arg2 (display "not cool")))) gives me an error of a type "procedure application: expected procedure, given: 2; arguments were: #void" That can be solved by placing that said conditional statement into different statements within a body of a defined function for example, with the conditional statement's body having separate statements every time as follows: (if (condition) statement1a statement2a) (if (condition) statement1b statement2b) and so on... It goes without saying that it's not too practical. Not to mention the duplicated code overhead. Am I missing anything here or is there really no other way?
Tags (comma-separated)
Save Edits
Cancel