How long would it take a programmer with one year of experience to write a function to get the initials from a name?

This will depend heavily on context and requirements, as Scott Berry wrote.
A simple implementation could be something like this:
Prelude Data.List.Split> let initials = map head . splitOn " "
or
>>> def initials(name):…     return ''.join(part[0] for part in name.split())
or
scala> def initials(name:String) : String = name.split(" ").map(_.head).mkString("")initials: (name: String)String
each of which take no more than 30 seconds to write . This will take the first letters of someone's name and returns them. "Ben Baert" would return "BB". That the literal meaning of initials.

Answer by Ben Baert:

This will depend heavily on context and requirements, as Scott Berry wrote.
A simple implementation could be something like this:
Prelude Data.List.Split> let initials = map head . splitOn " "
or
>>> def initials(name):
...     return ''.join(part[0] for part in name.split())
or
scala> def initials(name:String) : String = name.split(" ").map(_.head).mkString("")
initials: (name: String)String
each of which take no more than 30 seconds to write . This will take the first letters of someone's name and returns them. "Ben Baert" would return "BB". That the literal meaning of initials.
In terms of 'planning', this will be completely implicit to anyone with some experience, but it should consist of the following steps:
  1. Recognise that the full name string should be split into its parts (split at space) and
  2. take the first letter of each part and
  3. join those letters together.
There's of course the question of how to deal with special cases, and in a full program you'll deal with IO etc. But the basic functionality you asked about, a function that takes a name and outputs its initials really shouldn't take more than a couple of minutes to write in most programming languages, even for someone with not that much experience.

How long would it take a programmer with one year of experience to write a function to get the initials from a name?

Advertisements

Leave a comment

Filed under Life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s