Skip to content

Instantly share code, notes, and snippets.

@metric-space
Created October 11, 2015 17:37
Show Gist options
  • Save metric-space/3efda5b08446221928ef to your computer and use it in GitHub Desktop.
Save metric-space/3efda5b08446221928ef to your computer and use it in GitHub Desktop.
unique file name generator ..
import Data.List hiding (find )
import Data.Char
import System.FilePath.Find -- Sullivan's filemanip library
-- Responsible for splitting each file name into a list of substrings
myFunction :: [Char] -> String -> [String]
myFunction slig [] = []
myFunction splig something@(x:xs) = if (elem x splig ) then ( myFunction splig xs )
else let myF1 = takeWhile (\x -> ( elem x splig) == False) something
in [myF1]++myFunction splig (something \\ myF1)
create_name :: Int -> String
create_name x = "js-playground_"++show(x)++".html"
-- filters out other files that meet the file extension criteria but not the playground file criteria
filter_for_spec :: [[String]] -> [[String]]
filter_for_spec file_lsit = filter ( \x -> any (\y -> y == "js-playground") x ) file_lsit
main = do
ligne <- find always ( extension==? ".html") "."
let egg1 = sort $ map (\x -> x!!1)$ filter_for_spec $ [ (myFunction ['.','/','_'] x) | x <- ligne ]
print (egg1 !! ((length egg1)-1) )
return ()
-- work left :
-- 1. put in commandline argument terms to deal with you knwo what
-- 2. but in resource opening with Bracket function ...can't bloody remember the name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment