The Toolkit for Online Communities
16701 Community Members, 3 members online, 2528 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Q&A : Problem set 1 - Exercise 2

Forum OpenACS Q&A: Problem set 1 - Exercise 2

Icon of envelope Request notifications

Posted by Pavel Boghita on
I am not sure whether I understand correctly the term of 'constructor procedure' and its use in the context of the exercise.
I want to know whether my modification of the two_plus_two.adp answers correctly the point (2) of the exercise:

proc aquarium {name price} {
        global aquarium_types_and_costs
        lappend aquarium_types_and_costs "$name $price"

aquarium "some name" 60000
#... and so on, I've used aquarium procedure to add all the elements of the given list.
It gives the same result in the browser as the unmodified script

Posted by Alfred Werner on
Post a link to the original problem set ..
Posted by Pavel Boghita on
Posted by Michael Bluett on
I too am looking through the pset, having been through it on an Ars Digita bootcamp way back. Some of the links in the psets are broken, but can be found by searching archive.org for the URLs, and going back to about Feb 2002 for a working copy.

My answer to the aquarium problem was:

proc createAquariumRow {title cost number} {
	return [list $title $cost $number]

proc returnAquariumTitle {aquarium} {
	return [lindex $aquarium 0]

proc returnAquariumCost {aquarium} {
	return [lindex $aquarium 1]

proc returnAquariumNumber {aquarium} {
	return [lindex $aquarium 2]

proc returnAquariumSubtotal {aquarium} {
	return [expr [returnAquariumNumber $aquarium] * [returnAquariumCost $aquarium] ]

set aquarium_types_and_costs \
   [list [createAquariumRow "Lake Malawi Cichlid" 5000 2] \
         [createAquariumRow "Saltwater Community" 7000 3] \
         [createAquariumRow "Reef" 10000 4] \
         [createAquariumRow "Planted Freshwater" 6000 10] \
         [createAquariumRow "Suspended-in-midair Stingray Pond" 45000 1] \
         [createAquariumRow "Fish Tank" 1 1] \
If you have any other questions, just ask.

Posted by Michael Bluett on
The links in the pset are fixed (apart from those that don't have a replacement) after Carl updated the document with link corrections I sent him.

To follow convention I should have named my procs in lowercase with underscores between words (as in pa_grant_privilege_to_creator from photo album).