-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more fixtures / improve existing ones * These are really helpful for testing out the plugin while it's being written * Use row checks rather than starts for coincident nodes * Add more blacklist matchers * This here is the bummer. But since it's just the highlighting, with these the plugin is behaving more correctly than without. So maybe some day these can be sunset, but for now, they live on.
- Loading branch information
Showing
10 changed files
with
326 additions
and
278 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
// Structure to represent an account | ||
typedef struct { | ||
int accountNumber; | ||
float balance; | ||
} Account; | ||
|
||
// Function to create a new account | ||
Account* createAccount(int accountNumber, float initialBalance) { | ||
Account* newAccount = (Account*)malloc(sizeof(Account)); | ||
if (!newAccount) { | ||
printf("Memory error\n"); | ||
return NULL; | ||
} | ||
newAccount->accountNumber = accountNumber; | ||
newAccount->balance = initialBalance; | ||
return newAccount; | ||
} | ||
|
||
// Function to deposit money into an account | ||
void deposit(Account* account, float amount) { | ||
if (amount > 0.0f) { | ||
account->balance += amount; | ||
printf("Deposited $%.2f into account %d\n", amount, account->accountNumber); | ||
} else { | ||
printf("Invalid deposit amount: $%.2f\n", amount); | ||
} | ||
} | ||
|
||
// Function to withdraw money from an account | ||
void withdraw(Account* account, float amount) { | ||
if (amount > 0.0f && amount <= account->balance) { | ||
account->balance -= amount; | ||
printf("Withdrawn $%.2f from account %d\n", amount, account->accountNumber); | ||
} else { | ||
printf("Invalid withdrawal amount: $%.2f\n", amount); | ||
} | ||
} | ||
|
||
// Function to display account information | ||
void printAccountInfo(Account* account) { | ||
printf("Account Number: %d\nBalance: $%.2f\n", account->accountNumber, account->balance); | ||
} | ||
|
||
int main() { | ||
Account* account = createAccount(12345, 1000.00f); | ||
|
||
deposit(account, 500.00f); | ||
withdraw(account, 200.00f); | ||
printAccountInfo(account); | ||
|
||
free(account); | ||
return 0; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
import Data.List | ||
-- Import the necessary modules | ||
import Data.List (sort) | ||
import Control.Monad (replicateM) | ||
|
||
permutations :: [a] -> [[a]] | ||
permutations [] = [[]] | ||
permutations xs = do | ||
x <- xs | ||
xsRest <- permutations $ filter (/=x) xs | ||
return $ map (x:) xsRest | ||
-- Define a function to print out all even numbers in a list | ||
printEvens :: [Int] -> IO () | ||
printEvens [] = return () | ||
printEvens (x : xs) | ||
| x `mod` 2 == 0 = putStrLn (show x) >> printEvens xs | ||
| otherwise = printEvens xs | ||
|
||
-- Define a function to calculate the sum of all numbers in a list | ||
sumNumbers :: [Int] -> Int | ||
sumNumbers [] = 0 | ||
sumNumbers (x : xs) = x + sumNumbers xs | ||
|
||
-- Define a function to generate a random list of numbers | ||
randomList :: IO [Int] | ||
randomList = do | ||
n <- getLine | ||
let n' = read n :: Int | ||
replicateM n (getRandomR (-100, 100)) >>= return . sort | ||
|
||
-- Define a function to calculate the median of a list of numbers | ||
median :: [Double] -> Double | ||
median xs = median' (sort xs) | ||
where | ||
median' [] = error "Empty list" | ||
median' [_] = error "List contains single element" | ||
median' xs | ||
| odd len = fromIntegral $ xs !! (len `div` 2) | ||
| otherwise = mean | ||
where | ||
len = length xs | ||
mean = (sum xs) / fromIntegral len | ||
|
||
-- Main function to run the program | ||
main :: IO () | ||
main = do | ||
printEvens [1, 3, 5, 7, 9] | ||
print $ sumNumbers [-2, -4, 0, 10] | ||
randomList >>= mapM_ putStrLn . map show | ||
let xs = [-3.0, -1.0, 0.0, 1.0, 3.0] | ||
ys = [5.5, 6.6] | ||
print $ median xs | ||
print $ sumNumbers ys |
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
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
Oops, something went wrong.