Rewrite mkdir in your preferred language. mkdir should be able to leave you to a newly created directory
Example: user0@primary $ mkdir2 /home/user0/new/directory -c --- "/home/user0/new/directory" has been created, your current directory is " /new/directory/" ---
Meme language for a meme thread. #!/usr/bin/env python3 from os.path import expanduser import os import sys
def mkdir(dir): try: if os.path.exists(dir): print("ERROR: Directory already exists! Going there now...") os.chdir(dir) else: os.makedirs(dir) print("Directory created! Going there now...") os.chdir(dir) except OSError as e: print("ERROR: Directory could not be created!") print(e) sys.exit(1)
I think you're ignoring the last word in the title in this one. Make a new one.
Logan Jackson
(map mkdir (cdr (command-line)))
Gavin Taylor
my last two threads didn't have many solutions that actually worked.
I personally think Sup Forums skills to be CS first year level
Jeremiah Brown
If you make more completed problems you might get more posts.
Christopher Murphy
def create_dur(dirname) if Dir.exists?("dirname") then puts "Durr already exists" return else Dir.mkdir(dirname) puts "Durr created" Dir.entries(dirname) end end
Alexander Howard
The challenge is no good. >Rewrite mkdir in your preferred language This is a single standard library function call in just about any programming language. Unless you mean doing it at the syscall/direct disk manipulation level, but it doesn't seem so. >leave you to a newly created directory This, on the other hand, is impossible. You can't change the current directory of parent interpreter on Unix, except through very hackish means. stackoverflow.com/questions/2375003/how-do-i-set-the-working-directory-of-the-parent-process
Luke Murphy
Let me suggest an alternative challenge: write a program that reads a WBMP image file and prints its contents to the console.
def decode(bytes) do = bytes pixels = for Enum.concat() |> Enum.chunk(round8(width)) |> Enum.map(fn x -> Enum.slice(x, 0, width) end) %WBMP{width: width, height: height, image: pixels} end
def render(wbmp, on \\ "#", off \\ " ") do wbmp.image |> Enum.map(fn x -> x |> Enum.map(fn x -> if x == 0, do: on, else: off end) |> Enum.join() end) |> Enum.join("\n") end