An electromagnet is