mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	- some Erlang and escript files - .escript extension - .erlang extension - shell script with %, ##, name tokens
		
			
				
	
	
		
			22 lines
		
	
	
		
			413 B
		
	
	
	
		
			Erlang
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			413 B
		
	
	
	
		
			Erlang
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env escript
 | |
| %% -*- erlang -*-
 | |
| %%! -smp enable -sname factorial -mnesia debug verbose
 | |
| main([String]) ->
 | |
|     try
 | |
|         N = list_to_integer(String),
 | |
|         F = fac(N),
 | |
|         io:format("factorial ~w = ~w\n", [N,F])
 | |
|     catch
 | |
|         _:_ ->
 | |
|             usage()
 | |
|     end;
 | |
| main(_) ->
 | |
|     usage().
 | |
| 
 | |
| usage() ->
 | |
|     io:format("usage: factorial integer\n"),
 | |
|     halt(1).
 | |
| 
 | |
| fac(0) -> 1;
 | |
| fac(N) -> N * fac(N-1).
 |