{ meth Vec fmap:
    "Goldberg & Robson, 1989. p215"
    nc= / cls new .
    / do: [ x .
      nc ap: ( a runArg: x ) ] .
    nc
}

{ meth Vec select:
    "Goldberg & Robson, 1989. p216"
    nc= / cls new .
    / do: [ x .
      ( a runArg: x ) ye: [
        nc ap: x ] ] .
    nc
}

{ meth Obj tup
    "Create a Singleton Tuple (a Vector)."
    [ / ] vec
}
{ meth Obj tu:
    "Create a Tuple (a Vector) of Two Objects."
    [ / . a ] vec
}
{ meth Obj tu:tu:
    "Create a Tuple (a Vector) of Three Objects."
    [ / . a . b ] vec
}

{ class App Usr }
{ class TopApp App }

{ meth TopApp handle:body:
  "Default class for handling '/'."

  Map new  at: 'type' pu: 'list'
  	, at 'title' pu a
  	, at 'value' pu [
	  [ '@@@link|/Browse|Browse' . 'Browse Classes.' ] vec
	  [ '@@@link|/Cls|Cls' . 'The class named <Cls>.' ] vec
	] vec
	.
}

{ class Browse App }
{ meth Browse handle:body:
  ww= a spli: '[.]' .  "It's a regexp."
  wl= ww len .
  gm= Sys globalMap .

  "Start the list V with an UP link."
  v= [ '@@@link|/|TOP' tu: 'GOTO TOP.' ] vec .

  ( wl eq: 1 ) ye: [
    "gk are Good Keys, those that are classes."
    gk= gm dir select: [ i .
        AND{ gm at: i , cls nam ends: 'Cls' .
             gm at: i , nam ends: 'Cls' , not } ] .

    gk do: [ k .
        kc= gm at: k .
        kn= kc nam .
        v ap: ( '@@@link|/Browse.' ap: kn , ap: '|' , ap: kn , tu: kc meths str ) .
        ] .

    z= Map new  at: 'type' pu: 'list'
  	, at 'title' pu 'Browsing All Classes'
  	, at 'extra' pu ( gm )
  	, at 'extraKeys' pu ( gm dir )
  	, at 'extraFmap' pu ( gm dir fmap: [ i . ( gm at: i ) cls cls nam ] )
  	, at 'extraSelect' pu gk
  	, at 'value' pu v
	.
  ] .
  
  ( wl eq: 2 ) ye: [
    cn= ww at: 1 .  "class name"
    co= gm at: cn toLower .   "class object"

    d= co cls methd .
    d dir do: [ x . "For each class method"
      v ap: ( ( '@@@link|/EditMethod.' ap: cn , ap: 'Cls.' , ap: x , ap: '|class ' , ap: x ) , tu: ( d at: x , str ) ) . 
    ] .

    d= co methd .
    d dir do: [ x . "For each instance method"
      v ap: ( ( '@@@link|/EditMethod.' ap: cn , ap: '.' , ap: x , ap: '|' , ap: x ) tu: ( d at: x , str ) ) .
    ] .

    z= Map new  at: 'type' pu: 'list'
  	, at 'title' pu ( 'Browsing Class' ap: cn )
  	, at 'value' pu v
	.
  ] .
  z .
}

{ class EditMethod App }
{ meth EditMethod handle:body:
  ww= a spli: '[.]' .  "It's a regexp."
  wl= ww len .
  gm= Sys globalMap .

  ( wl ne: 3 ) ye: [ Zork foo ] .

  cn= ww at: 1 .  "class name"
  mn= ww at: 2 .  "method name"

  co= gm at: cn toLower .   "class object"
  mo= co methd at: mn .  "method object"

  z= Map new  at: 'type' pu: 'edit'
  	, at 'title' pu ( 'Editing Class' ap: cn , ap: ' Method ' , ap: mn )
  	, at 'value' pu ( mo str )
  	, at 'action' pu ( '/SubmitMethod.' ap: cn , ap: '.' , ap: mn )
	.
  z
}

{ class SubmitMethod App }
{ meth SubmitMethod handle:body:
  ww= a spli: '[.]' .  "It's a regexp."
  wl= ww len .
  gm= Sys globalMap .

  ( wl ne: 3 ) ye: [ Zork foo ] .

  cn= ww at: 1 .  "class name"
  mn= ww at: 2 .  "method name"

  co= gm at: cn toLower .   "class object"

  z= Map new  at: 'type' pu: 'text'
  	, at 'title' pu ( 'Submitting (NOT REALLY) Class' ap: cn , ap: ' Method ' , ap: mn )
  	, at 'value' pu b
	.
  z
}
