Ch 4 - Case Study: Interface Design Flashcards

1
Q

Think Julia

What is a: module

A

A module is a file that contains a collection of related functions. Julia provides some modules in its standard library. Additional functionality can be added from a growing collection of packages.

Ben Lauwens and Allen B. Downey. thinkjulia (Kindle Locations 1076-1078). Kindle Edition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Think Julia

What is a: import

A

Before we can use the functions in a module, we have to import it with a using statement:

julia > using ThinkJulia

julia > 🐢 = Turtle()
Luxor.Turtle( 0.0, 0.0, true, 0.0, (0.0, 0.0, 0.0))

Ben Lauwens and Allen B. Downey. thinkjulia (Kindle Locations 1084-1089). Kindle Edition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Think Julia

What is a: @svg

A

Once you create a turtle, you can call a function to move it around. For example, to move the turtle forward:

@svg begin
….forward( 🐢, 100)
end

The @svg keyword runs a macro that draws an SVG picture (Figure 4-1). Macros are an important but advanced feature of Julia.

Ben Lauwens and Allen B. Downey. thinkjulia (Kindle Locations 1095-1103). Kindle Edition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Think Julia

What is a: docstring

A

A docstring is a string before a function that explains the interface (“ doc” is short for “documentation”). Here is an example:

””“ polyline( t, n, len, angle)

Draws n line segments with the given length and angle (in degrees) between them. t is a turtle. ””“
function polyline( t, n, len, angle)
….for i in 1: n
……..forward( t, len)
……..turn( t, -angle)
….end
end

Documentation can be accessed in the REPL or in a notebook by typing ? followed by the name of a function or macro, and pressing Enter:

Ben Lauwens and Allen B. Downey. thinkjulia (Kindle Locations 1356-1371). Kindle Edition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Think Julia

How can a docstring be accessed in a REPL?

A

A docstring is a string before a function that explains the interface (“ doc” is short for “documentation”). Here is an example:

””“ polyline( t, n, len, angle)

Draws n line segments with the given length and angle (in degrees) between them. t is a turtle. ””“
function polyline( t, n, len, angle)
….for i in 1: n
……..forward( t, len)
……..turn( t, -angle)
….end
end

Documentation can be accessed in the REPL or in a notebook by typing ? followed by the name of a function or macro, and pressing Enter:

Ben Lauwens and Allen B. Downey. thinkjulia (Kindle Locations 1356-1371). Kindle Edition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly