Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Task 1 Reading In Lists Clarification
#1
The example only shows one list being supplied:
Code:
echo "((0 1))" >> task1.args

However, how should we expect more than one list? As a set of arguments, a list of lists, or as separate arguments on new lines?
Code:
echo "((0 1) (1 2) (1 4))" >> task1.args

or

echo "(((0 1) (1 2) (1 4)))" >> task1.args

or

echo "((0 1))" >> task1.args
echo "((1 2))" >> task1.args
echo "((1 4))" >> task1.args
UA ACM Vice President
ACM has bi-weekly meetings Tuesdays at 5:15pm
We're UA's best organization for CS majors (website)
Join us on Slack for all kinds of discussion channels (including one for CS403)
Reply
#2
A list of lists.
Reply
#3
In case anyone is confused:

You can provide a function f with the elements of a list as arguments instead of the list itself by using (apply f list-of-arguments)

So, this:
      (apply f (a b c))
is the same as
      (f a b c)

In contrast, if you were to call (f (a b c)), f will see only one argument: the list (a b c).
Reply
#4
(09-28-2017, 09:59 PM)james_h Wrote: You can provide a function f with the elements of a list as arguments instead of the list itself by using (apply f list-of-arguments)

...keep in mind you may need to construct an object to apply f to if you can't put it in a list!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)