add functional d solution. rename "classic for" to imperative