Explore snippets
Discover reusable code snippets, examples, fixes, and ideas shared by developers, students, and teams.
Recursive mathematical and list functions in Haskell
Defines various recursive functions for summation, power calculations, and list operations in Haskell, including sums over ranges, power com...
module Gyak05 where
sumTo :: Integer -> Integer
sumTo x
| x <= 0 = 0
| otherwise = x + sumTo (x-1)
sumBetweenHelper :: Integer -> Integer -> Integer
sumBetweenHelper n m
| n == m = n
| otherwise = sumBetweenHelper n (m-1) + m
Guest class managing prizes in a game
Defines a Guest class that tracks a guest's name and the prizes (gifts) they have won, allowing addition of prizes and calculating the total...
using System;
using System.Collections.Generic;
namespace HF10
{
internal class Guest
{
private string name;
private List<Gift> prizes;
public string Name
{
get { return name; }
}
Singleton Pattern in C#
Defines a singleton class with a static instance method ensuring a single object and a method returning a fixed integer.
namespace HF10
{
internal class S : ISize
{
private static S instance = null;
private S()
{
}
public static S Instance()
{
if (instance == null)
{
Egyszerű HTML oldal alapértelmezett címkékkel
Ez a HTML kód létrehoz egy alap weboldalt egy fejléccel és egy bekezdéssel.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Center.cs
using System;
using System.Collections.Generic;
namespace HF07
{
internal class Center
{
private List<Bank> bankok;
public Center(List<Bank> bankok)
{
this.bankok = bankok;
}
ATM.cs
using System;
namespace HF07
{
internal class ATM
{
private string location;
private Center center;
public ATM(string location, Center center)
{
this.location = location;
this.center = center;
Basic Haskell Math and Utility Functions
Defines several mathematical and utility functions in Haskell including calculations for circle area, sphere volume, temperature conversion,...
module Gyak04 where
import Data.Char(toLower, toUpper, isLower, isUpper)
circleArea :: Double -> Double
circleArea r = (r^2)*pi
sphereVolume :: Double -> Double
sphereVolume r = 4*(r^3)*pi/3
cToF :: Double -> Double