Introducing a helper function for sml to write in memory