Create a list that stores the courses that you are taking this semester where th
ID: 3773018 • Letter: C
Question
Create a list that stores the courses that you are taking this semester where the courses are stored in sublists as (subjectnumber) such as (CSCI 755) so that your list will look like this: ((CSCI 755) (EENG 641) (ACCT 801) (CHEM 601) (ENGY 720)) and then create 3 other lists for fictitious CSCI and/or EENG majors. All students should have at least one CSCI class. They should all have at least 2 courses, no more than 7 Write the following functions a. Given a subject, print all courses of that subject b. Print all upper level courses (7xx and 8xx courses) c. Count the number of courses that are either CSCI or EENG and return that number d. Given a course list, determine whether a given schedule is “hard”, “easy” or “inbetween”. Where a “hard” schedule is one where the student is taking only upper level courses or only CSCI/EENG courses; an “easy” schedule is one where the student is taking only lower level courses or is one with no CSCI/EENG courses; and “inbetween” is everything else.
Explanation / Answer
Declare that a list of variables is for use within the body of the let and give them an initial value, either nil or a specified value; then evaluate the rest of the expressions in the body of the let and return the value of the last one. Inside the body of the let, the Lisp interpreter does not see the values of the variables of the same names that are bound outside of the let.
For example,
save-excursion
Record the values of point and mark and the current buffer before evaluating the body of this special form. Restore the values of point and mark and buffer afterward.
For example,
if
Evaluate the first argument to the function; if it is true, evaluate the second argument; else evaluate the third argument, if there is one.
The if special form is called a conditional. There are other conditionals in Emacs Lisp, but if is perhaps the most commonly used.
For example,
<
>
<=
>=
The < function tests whether its first argument is smaller than its second argument. A corresponding function, >, tests whether the first argument is greater than the second. Likewise, <= tests whether the first argument is less than or equal to the second and >= tests whether the first argument is greater than or equal to the second. In all cases, both arguments must be numbers or markers (markers indicate positions in buffers).
=
The = function tests whether two arguments, both numbers or markers, are equal.
equal
eq
Test whether two objects are the same. equal uses one meaning of the word ‘same’ and eq uses another: equal returns true if the two objects have a similar structure and contents, such as two copies of the same book. On the other hand, eq, returns true if both arguments are actually the same object.
string<
string-lessp
string=
string-equal
The string-lessp function tests whether its first argument is smaller than the second argument. A shorter, alternative name for the same function (adefalias) is string<.
The arguments to string-lessp must be strings or symbols; the ordering is lexicographic, so case is significant. The print names of symbols are used instead of the symbols themselves.
An empty string, ‘""’, a string with no characters in it, is smaller than any string of characters.
string-equal provides the corresponding test for equality. Its shorter, alternative name is string=. There are no string test functions that correspond to>, >=, or <=.
list-length list
list-length returns, as an integer, the length of list. list-length differs from length when the list is circular; length may fail to return, whereas list-length will return nil. For example:
list-length could be implemented as follows:
See length, which will return the length of any sequence.
[Function]
nth n list
(nth n list) returns the nth element of list, where the car of the list is the ``zeroth'' element. The argument n must be a non-negative integer. If the length of the list is not greater than n, then the result is (), that is, nil. (This is consistent with the idea that the car and cdr of () are each ().) For example:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.