Question
Consider the following C code which has several memory-related problems (but compiles, and even gives reasonable output sometimes!): #include #include struct person { char* name;
Consider the following C code which has several memory-related problems (but compiles, and even gives reasonable output sometimes!):
#include
#include
struct person {
char* name;
};
struct person* create_person(char* name){
struct person newperson = {name};
return &newperson;
}
int main() {
char *str = malloc(sizeof(char) * 10);
printf("Enter a name: ");
scanf("%s", str);
if (str) {
struct person* p1 = create_person(str);
printf("Your person's name: \"%s\" ", p1->name);
free(str);
}
return 0;
}
Use this for the next few questions.
1. Consider the functional programming concept of higher order functions. Find example code illustrating this concept and written in Clojure somewhere on the internet, paste it in, and explain how it works and how it exhibits the concept.
2.Consider the functional programming concept of lazy evaluation. Find example code illustrating this concept and written in Clojure somewhere on the internet, paste it in, and explain how it works and how it exhibits the concept.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started