This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative | |
import System.Environment | |
import System.Exit | |
import System.Random | |
main = getArgs >>= parseArgs | |
-- Exit with success. | |
exit :: IO a | |
exit = exitWith ExitSuccess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Skriv en funktion der returnerer strengen: | |
-- This is an amazingly interesting sentence! | |
??? | |
-- Skriv en funktion der returnerer hvor mange gange a findes i [a] | |
countSomething :: Eq a => a -> [a] -> Int | |
countSomething ??? | |
-- Skriv ovenstående funktion i 3 udgaver: | |
-- 1. En der løser opgaven med list comprehension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'dart:io'; | |
main(Args args) { | |
print(UTF8.decode(new File(args[0]).readAsBytesSync()) | |
.split('AND') | |
.map((s) => s.trim()) | |
.toList() | |
.join(' AND\n')); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Alle steder i ser ??? skal i skrive noget. | |
-- For bonuspoint: | |
-- Læs mere om List Comprehension her http://learnyouahaskell.com/starting-out (langt nede på siden) | |
-- Opgave 1 | |
-- Definer to type synonymer kaldet Name og Names. | |
-- Name skal være et synonym for String og Names for liste af Name. | |
??? | |
??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Lets pretty print a Book! | |
-- | |
-- A couple of type synonyms for readability. | |
type Title = String | |
type Authors = [String] | |
-- Our Book data type. | |
-- A book consists of an isbn number, a title and a list of authors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library shelfmiddleware.checktoken; | |
import 'headers.dart'; | |
import 'token.dart'; | |
import 'package:shelf/shelf.dart' as shelf; | |
import 'package:shelf_path/shelf_path.dart'; | |
final shelf.Middleware checkToken = shelf.createMiddleware(requestHandler: _passOrForbid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library shelfmiddleware.headers; | |
import 'dart:io' show HttpHeaders; | |
const Map<String, String> textHtmlHeader = const {HttpHeaders.CONTENT_TYPE: 'text/html'}; | |
const Map<String, String> CORSHeader = const {'Access-Control-Allow-Origin': '*'}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library shelfmiddleware.token; | |
final List<String> _validTokens = new List<String>(); | |
bool isValid(String token) => _validTokens.contains(token); | |
String getToken() { | |
final String token = new DateTime.now().millisecondsSinceEpoch.toString(); | |
_validTokens.add(new DateTime.now().millisecondsSinceEpoch.toString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library shelfmiddleware.handlers; | |
import 'headers.dart'; | |
import 'package:shelf/shelf.dart' as shelf; | |
import 'package:shelf_path/shelf_path.dart'; | |
shelf.Response app(shelf.Request request) { | |
final String myToken = getPathParameter(request, 'token'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library shelfmiddleware.routes; | |
import 'handlers.dart' as handler; | |
import 'package:shelf_route/shelf_route.dart'; | |
final Router routes = new Router() | |
..get('/app{?token}', handler.app) | |
..get('/foo{?token}', handler.foo); |
NewerOlder