text:
module Part1.Sec2_2_2_the

||| reimplemented "the" function from Prelude
the' : (ty : Type) -> ty -> ty
the' ty x = x

ext: idr

max_stars_repo_name: rpeszek/IdrisTddNotes

max_issues_repo_name: rpeszek/IdrisTddNotes

max_forks_repo_name: rpeszek/IdrisTddNotes

lm_label:
1. NO
2. NO


text:
-- exercises in "Type-Driven Development with Idris"
-- chapter 2

-- exercise 1
val1 : (String, String, String)
val1 = ("A", "B", "C")
val2 : List String
val2 = ["A", "B", "C"]
val3 : ((String, String), String)
val3 = (("A", "B"), "C")

-- exercise 2
palindrome : String -> Bool
palindrome x = x == reverse x

-- exercise 3
palindrome2_1 : String -> Bool
palindrome2_1 x = let x' = toLower x in x' == reverse x'

palindrome2_2 : String -> Bool
palindrome2_2 x = palindrome (toLower x)

palindrome2_3 : String -> Bool
palindrome2_3 x = x' == (reverse x')
  where
    x' : String
    x' = toLower x

palindrome2_4 : String -> Bool
palindrome2_4 x = palindrome $ toLower x -- using $ instead of ()s

-- exercise 4
palindrome3_1 : String -> Bool
palindrome3_1 x = case length x >= 10 of
                        False => False
                        True => palindrome2_1 x

palindrome3_2 : String -> Bool
palindrome3_2 x = if length x >= 10
                      then palindrome2_1 x
                      else False

palindrome3_3 : String -> Bool
palindrome3_3 x = (length x >= 10) && palindrome2_1 x

-- exercise 5
palindrome4_1 : Nat -> String -> Bool
palindrome4_1 n x = case length x >= n of
                        False => False
                        True => palindrome2_1 x

palindrome4_2 : Nat -> String -> Bool
palindrome4_2 n x = if length x >= n
                      then palindrome2_1 x
                      else False

palindrome4_3 : Nat -> String -> Bool
palindrome4_3 n x = (length x >= n) && palindrome2_1 x

-- exercise 6
counts : String -> (Nat, Nat)
counts str = (length (words str), length str)

-- exercise 7
top_ten_1 : Ord a => List a -> List a
top_ten_1 xs = take 10 (reverse (sort xs))

top_ten_2 : Ord a => List a -> List a
top_ten_2 xs = take 10 $ reverse $ sort xs -- using $ instead of ()s

top_ten_3 : Ord a => List a -> List a
top_ten_3 xs = (Prelude.List.take 10) . reverse . sort $ xs -- using .

top_ten_4 : Ord a => List a -> List a
top_ten_4 = (Prelude.List.take 10) . reverse . sort -- using . & eta-reduction

-- exercise 8
over_length_1 : Nat -> List String -> Nat
over_length_1 k [] = 0
over_length_1 k (x :: xs) = case length x > k of
                               False => over_length_1 k xs
                               True => 1 + over_length_1 k xs

over_length_2 : Nat -> List String -> Nat
over_length_2 k xs = length (filter lengthMoreThanK xs) -- using filtering
                      where
                        lengthMoreThanK : String -> Bool
                        lengthMoreThanK str = length str > k

over_length_3 : Nat -> List String -> Nat
over_length_3 k xs = length (filter (\x => length x > k) xs) -- using lambda

over_length_4 : Nat -> List String -> Nat
over_length_4 k xs = let ls = map length xs in -- using map and filtering
                      length $ filter (> k) ls

-- exercise 9
-- run with ":exec ex9_1" or ":exec ex9_2" (or use a function main in a module Main)
ex9_1 : IO ()
ex9_1 = repl "Enter a string: " show_palindrome2_1
  where
    show_palindrome2_1 str = show (palindrome2_1 str) ++ "\n"

ex9_2 : IO ()
ex9_2 = repl "Enter a string: " show_counts
  where
    show_counts str = show (counts str) ++ "\n"

max_stars_repo_name: pascalpoizat/idris-book

max_issues_repo_name: pascalpoizat/idris-book

max_forks_repo_name: pascalpoizat/idris-book


text:
module Reverse

reverse' : List a -> List a
reverse' xs = revAcc [] xs where
  revAcc : List a -> List a -> List a
  revAcc acc [] = acc
  revAcc acc (x :: xs) = revAcc (x :: acc) xs

max_stars_repo_name: aztecrex/try-idris

max_issues_repo_name: aztecrex/try-idris

max_forks_repo_name: aztecrex/try-idris


text:
module Test.Asserts

%default total
%access public export

assertEq : Eq a => (given : a) -> (expected : a) -> IO ()
assertEq g e = if g == e
    then putStrLn "Test Passed"
    else putStrLn "Test Failed"

max_stars_repo_name: rpeszek/idris-chain

max_issues_repo_name: rpeszek/idris-chain

max_forks_repo_name: rpeszek/idris-chain


text:
-- ----------------------------------------------------------------- [ Org.idr ]
-- Module    : Org.idr
-- Copyright : (c) Jan de Muijnck-Hughes
-- License   : see LICENSE
-- --------------------------------------------------------------------- [ EOH ]
module Text.Markup.Edda.Test.Org

import Text.Markup.Edda.Model
import Text.Markup.Edda.Reader.Org

import Lightyear.Testing

export
runTests : IO ()
runTests = Testing.runTests [
      parseTest ( "Markup") (many $ lexeme inline) "asasas *bold* /italic/ ~code~ +strike-through+ =verbatim= $mart$ Hello 'Bye bye'.\n"

    , parseTest ( "Links 1") (many inline) "[[http://www.cs.st-andrews.ac.uk][URL]] [[http://www.cs.st-andrews.ac.uk][URL]] [[http://www.cs.st-andrews.ac.uk][URL]]\n"

    , parseTest ( "Links 2") (many inline) "[[http://www.cs.st-andrews.ac.uk]] [[Boneh2001]] [[citet:Boneh2001]] [[citep:Boneh2001]]\n"

    , parseTest ( "Links 3") (many inline) "[fn:label:description]\n"

    , parseTest ("Attribute Title")  (attribute "TITLE")  "#+TITLE: I am a Title\n\n"
    , parseTest ("Attribute Author") (attribute "AUTHOR") "#+AUTHOR: I am an Author\n\n"
    , parseTest ("Attribute Date ")  (attribute "DATE")   "#+DATE: I is a date\n\n"

    , parseTest ( "Environments")
                (many block)
                """#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_THEOREM
sdsdsdsd
#+END_THEOREM
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_COROLLARY
sdsdsdsd
#+END_COROLLARY
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_LEMMA
sdsdsdsd
#+END_LEMMA
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_PROPOSITION
sdsdsdsd
#+END_PROPOSITION
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_PROOF
sdsdsdsd
#+END_PROOF
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_DEFINITION
sdsdsdsd
#+END_DEFINITION
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_EXAMPLE
sdsdsdsd
#+END_EXAMPLE
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_EXERCISE
sdsdsdsd
#+END_EXERCISE
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_NOTE
sdsdsdsd
#+END_NOTE
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_PROBLEM
sdsdsdsd
#+END_PROBLEM
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_QUESTION
sdsdsdsd
#+END_QUESTION
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_REMARK
sdsdsdsd
#+END_REMARK
#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_SOLUTION
sdsdsdsd
#+END_SOLUTION
"""

    , parseTest ( "Headers")
                (many header)
                """* Introduction

** Contribution

** Outline

* Methodology

** System

** Procedure

* Results

* Discussion

* Conclusion

"""

    , parseTest ( "Source Block 1")
                (orgBlock)
                """#+CAPTION: sdsd
#+NAME: asas:asasre
#+BEGIN_SRC idris

main : IO ()
main = putStrLn "Hello World!"
#+END_SRC

"""

    , parseTest ( "Source Block 2")
                (orgBlock)
                """#+BEGIN_SRC idris
main : IO ()
main = putStrLn "Hello World!"
main : IO ()
main = putStrLn "Hello World!"
#+END_SRC

"""

    , parseTest ( "Quotes")
                (orgBlock)
                """#+BEGIN_QUOTE
dfkljfzdjf
#+END_QUOTE

"""

    , parseTest ( "Figures")
           (orgBlock)
           """#+CAPTION: sdsd
#+NAME: asas:asasre
[[dfjkdjfldjkf]]

"""

    , parseTest ( "Equations")
                (many orgBlock)
                """#+BEGIN_EQUATION
y = a*x^2 + b*x + c
#+END_EQUATION

#+NAME: asas
#+BEGIN_EQUATION
y^2 = x^3 + ax + b
#+END_EQUATION

"""

    , parseTest ("Lists")
                (many orgBlock)
                """+ a
+ b
+ c
+ a
+ b
+ c
- a
- b
- c

1. a
1. b
2. c
3. a
3. b
1. c
2. a
2. b
3. c

+ Term :: Description
+ Term :: Description
+ Term :: Description
+ Term :: Description
+ Term :: Description
+ Term :: Description

"""
    ]
-- --------------------------------------------------------------------- [ EOF ]

max_stars_repo_name: jfdm/edda

max_issues_repo_name: jfdm/edda

max_forks_repo_name: jfdm/edda


text:
-- | Exercises on Equality.
module Koans.Equality

equalityEq : Bool
equalityEq = ?fillme1 == True

equalityNeq : Bool
equalityNeq = ?fillme2 /= 3

equalityGeq : Bool
equalityGeq = ?fillme3 >= 4

equalityGtr : Bool
equalityGtr = ?fillme4 > 4

equalityLeq : Bool
equalityLeq = ?fillme5 <= 5

equalityLess : Bool
equalityLess = ?fillme6 < 6

-- --------------------------------------------------------------------- [ EOF ]

max_stars_repo_name: yurrriq/idris-koans

max_issues_repo_name: TheWizardTower/idris-koans

max_forks_repo_name: yurrriq/idris-koans


text:
-- examples in "Type-Driven Development with Idris"
-- chapter 13, section 1

-- check that all functions are total
%default total

--
-- see Door.idr
-- see VendingMachine.idr
--


text:
module Example.Qtt.Range

import Data.Vect

fromMaybe' : a -> (1 _ : Maybe a) -> a
fromMaybe' _ (Just x) = x
fromMaybe' d Nothing  = d

f : a -> Vect n (Maybe a) -> Vect n a
f x = map (\y => fromMaybe' x y)

max_stars_repo_name: buzden/code-in-lectures

max_issues_repo_name: buzden/code-in-lectures

max_forks_repo_name: buzden/code-in-lectures


text:
-- https://www.codewars.com/kata/50654ddff44f800200000004

module Multiply

%access export
%default total

multiply : Int -> Int -> Int
multiply a b = a * b

max_stars_repo_name: hiljusti/codewars-solutions

max_issues_repo_name: hiljusti/codewars-solutions

max_forks_repo_name: hiljusti/codewars-solutions