Skip to content

WolfCode is a playful, wolf-themed programming language designed to teach basic programming concepts. It uses wolf pack terminology to represent various programming constructs.

License

Notifications You must be signed in to change notification settings

cobluestars/WolfCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸบWolfCode Language Specification๐Ÿบ

1. Introduction:

  • WolfCode is a playful, wolf-themed programming language designed to teach basic programming concepts. It uses wolf pack terminology to represent various programming constructs.

2. Data Types:

  • Bone: Represents integer values * Example: Howl my_bone as Bone
  • Meat: Represents floating-point values * Example: Howl my_meat as Meat
  • Biscuit: Represents boolean values (crunchy = true, soft = false) * Example: Howl my_biscuit as Biscuit

3. Variables and Assignment:

  • Declaration: "Howl [name] as [type]" * Example: Howl age as Bone
  • Assignment: "Mark [name] with [value]" * Example: Mark age with 5

4. Basic Operators:

  • Addition: "Fetch [bone1] and [bone2]" * Example: Fetch age and 3
  • Subtraction: "Chase [bone1] from [bone2]" * Example: Chase 2 from age
  • Multiplication: "Bury [bone1] [bone2] times" * Example: Bury age 2 times
  • Division: "Share [bone1] among [bone2] pack members" * Example: Share age among 2 pack members
  • Comparison: "Sniff [bone1] and [bone2]" (returns Biscuit) * Example: Sniff age and 10

5. Control Structures:

  • If statement:
  "If [condition] then
     [action]
  else
     [other action]
  Pack decides"
  • While loop:
   "While [condition] do
      [actions]
   Pack rests"
  • For loop:
   "For each [item] in [collection] do
      [actions]
   Pack moves on"

6. Input/Output:

  • Input: "Listen for [variable]" * Example: Listen for age
  • Output: "Howl [message]" * Example: Howl "Your age is: " age

7. Memory Model:

  • The den is represented as an infinite series of caves
  • Each cave stores one data item (Bone, Meat, or Biscuit)
  • Navigate using: "Dig [direction] to [cave_name]" * Example: Dig north to age_cave

8. Jump Commands:

  • Unconditional jump: "Run to [label]" * Example: Run to start_loop
  • Conditional jump: "If [condition] then run to [label]" * Example: If Sniff age and 18 then run to adult_section

9. Function Definition:

  • Define function:
  "Teach pack [function_name]
     [function body]
  Pack learned [function_name]"
  • Call function: "Do [function_name]"

10. Comments:

- Single line: "// [comment]"
- Multi-line: "/* [comment] */"

11. Program Structure:

- Start: "Pack gathering"
- End: "Pack dispersing"

Example Programs:

1. Basic Arithmetic:

Pack gathering

Howl "Let's do some wolf math!"

Howl num1 as Bone
Howl num2 as Bone

Listen for num1
Listen for num2

Howl sum as Bone
Mark sum with Fetch num1 and num2
Howl "Sum: " sum

Howl diff as Bone
Mark diff with Chase num2 from num1
Howl "Difference: " diff

Howl product as Bone
Mark product with Bury num1 num2 times
Howl "Product: " product

Howl quotient as Meat
Mark quotient with Share num1 among num2 pack members
Howl "Quotient: " quotient

Pack dispersing

2. Control Structures:

Pack gathering

Howl "Counting bones!"

Howl count as Bone
Mark count with 1

While Sniff count and 11 do
    Howl "Bone count: " count
    Mark count with Fetch count and 1
Pack rests

Howl "Even or Odd?"

For each num in count do
    If Share num among 2 pack members then
        Howl num " is even"
    else
        Howl num " is odd"
    Pack decides
Pack moves on

Pack dispersing

3. Function Example:

Pack gathering

Teach pack calculate_dog_years
    Listen for human_years
    Howl dog_years as Bone
    Mark dog_years with Bury human_years 7 times
    Howl "In dog years, that's: " dog_years
Pack learned calculate_dog_years

Howl "Enter your age in human years:"
Do calculate_dog_years

Pack dispersing

4. Hello World Example:

Pack gathering

// Declare variables for each character
Howl h as Bone
Howl e as Bone
Howl l as Bone
Howl o as Bone
Howl space as Bone
Howl w as Bone
Howl r as Bone
Howl d as Bone
Howl exclamation as Bone

// Assign ASCII values
Mark h with 72  // ASCII for 'H'
Mark e with 101 // ASCII for 'e'
Mark l with 108 // ASCII for 'l'
Mark o with 111 // ASCII for 'o'
Mark space with 32 // ASCII for space
Mark w with 87  // ASCII for 'W'
Mark r with 114 // ASCII for 'r'
Mark d with 100 // ASCII for 'd'
Mark exclamation with 33 // ASCII for '!'

// Combine characters to form the message
Howl message as Bone
Mark message with Fetch h and e
Mark message with Fetch message and l
Mark message with Fetch message and l
Mark message with Fetch message and o
Mark message with Fetch message and space
Mark message with Fetch message and w
Mark message with Fetch message and o
Mark message with Fetch message and r
Mark message with Fetch message and l
Mark message with Fetch message and d
Mark message with Fetch message and exclamation

// Output the message
Howl message

Pack dispersing

WolfCode ์–ธ์–ด ์„ค๋ช…

1. ์†Œ๊ฐœ

  • WolfCode๋Š” ๋Š‘๋Œ€ ๋ฌด๋ฆฌ์˜ ์šฉ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ตฌ์กฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ, ๊ธฐ๋ณธ์ ์ธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ฐœ๋…์„ ๊ฐ€๋ฅด์น˜๋Š” ์žฌ๋ฏธ์žˆ๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค.
  • ๋งŒ๋“  ์ด: cobaltbluestars(Renard), Raika the Wolfdog

2. ๋ฐ์ดํ„ฐ ํƒ€์ž…

  • Bone: ์ •์ˆ˜ํ˜• ๊ฐ’
  • ์˜ˆ: Howl my_bone as Bone
  • Meat: ๋ถ€๋™ ์†Œ์ˆ˜์  ๊ฐ’
  • ์˜ˆ: Howl my_meat as Meat
  • Biscuit: ๋ถˆ๋ฆฌ์–ธ ๊ฐ’ (crunchy = ์ฐธ, soft = ๊ฑฐ์ง“)
  • ์˜ˆ: Howl my_biscuit as Biscuit

3. ๋ณ€์ˆ˜ ์„ ์–ธ ๋ฐ ํ• ๋‹น

  • ๋ณ€์ˆ˜ ์„ ์–ธ: Howl [์ด๋ฆ„] as [ํƒ€์ž…]
  • ์˜ˆ: Howl age as Bone
  • ๊ฐ’ ํ• ๋‹น: Mark [์ด๋ฆ„] with [๊ฐ’]
  • ์˜ˆ: Mark age with 5

4. ๊ธฐ๋ณธ ์—ฐ์‚ฐ์ž

  • ๋ง์…ˆ: Fetch [bone1] and [bone2]
  • ์˜ˆ: Fetch age and 3
  • ๋บ„์…ˆ: Chase [bone1] from [bone2]
  • ์˜ˆ: Chase 2 from age
  • ๊ณฑ์…ˆ: Bury [bone1] [bone2] times
  • ์˜ˆ: Bury age 2 times
  • ๋‚˜๋ˆ—์…ˆ: Share [bone1] among [bone2] pack members
  • ์˜ˆ: Share age among 2 pack members
  • ๋น„๊ต: Sniff [bone1] and [bone2] (Biscuit์„ ๋ฐ˜ํ™˜)
  • ์˜ˆ: Sniff age and 10

5. ์ œ์–ด ๊ตฌ์กฐ

  • If ์กฐ๊ฑด๋ฌธ:
If [์กฐ๊ฑด] then
  [ํ–‰๋™]

else
  [๋‹ค๋ฅธ ํ–‰๋™]

Pack decides

-While ๋ฐ˜๋ณต๋ฌธ:

While [์กฐ๊ฑด] do
  [ํ–‰๋™]

Pack rests
  • For ๋ฐ˜๋ณต๋ฌธ:
For each [ํ•ญ๋ชฉ] in [์ปฌ๋ ‰์…˜] do
  [ํ–‰๋™]

Pack moves on

6. ์ž…์ถœ๋ ฅ:

  • ์ž…๋ ฅ ๋ฐ›๊ธฐ: Listen for [๋ณ€์ˆ˜]
  • ์˜ˆ: Listen for age
  • ์ถœ๋ ฅํ•˜๊ธฐ: Howl [๋ฉ”์‹œ์ง€]
  • ์˜ˆ: Howl "Your age is: " age

7. ๋ฉ”๋ชจ๋ฆฌ ๋ชจ๋ธ

  • Den์€ ๋ฌดํ•œํ•œ "caves"๋กœ ํ‘œํ˜„๋จ

  • ๊ฐ cave๋Š” ํ•˜๋‚˜์˜ ๋ฐ์ดํ„ฐ ํ•ญ๋ชฉ(Bone, Meat, ๋˜๋Š” Biscuit)์„ ์ €์žฅ

  • ํƒ์ƒ‰: Dig [๋ฐฉํ–ฅ] to [cave_name]

  • ์˜ˆ: Dig north to age_cave

8. ์ ํ”„ ๋ช…๋ น์–ด

  • ๋ฌด์กฐ๊ฑด ์ ํ”„: Run to [label]
  • ์˜ˆ: Run to start_loop
  • ์กฐ๊ฑด๋ถ€ ์ ํ”„: If [์กฐ๊ฑด] then run to [label]
  • ์˜ˆ: If Sniff age and 18 then run to adult_section

9. ํ•จ์ˆ˜ ์ •์˜

  • ํ•จ์ˆ˜ ์ •์˜:
Teach pack [ํ•จ์ˆ˜๋ช…]
  [ํ•จ์ˆ˜ ๋‚ด์šฉ]
Pack learned [ํ•จ์ˆ˜๋ช…]
  • ํ•จ์ˆ˜ ํ˜ธ์ถœ: Do [ํ•จ์ˆ˜๋ช…]

10. ์ฃผ์„

  • ๋‹จ์ผ ์ค„ ์ฃผ์„: // [์ฃผ์„ ๋‚ด์šฉ]
  • ์—ฌ๋Ÿฌ ์ค„ ์ฃผ์„: /* [์ฃผ์„ ๋‚ด์šฉ] */

11. ํ”„๋กœ๊ทธ๋žจ ๊ตฌ์กฐ

  • ์‹œ์ž‘: Pack gathering
  • ๋: Pack dispersing

WolfCode Quick Sort


Pack gathering

// ๋Š‘๋Œ€ ๋ฌด๋ฆฌ ์„ ์–ธ
Howl wolf_pack as Den
Mark wolf_pack with [{"name": "leo", "age": 5}, {"name": "jax", "age": 3}, {"name": "matt", "age": 2}, {"name": "renard", "age": 1}]

// ํ€ต ์ •๋ ฌ ํ•จ์ˆ˜ ์ •์˜
Teach pack quick_sort
    Listen for wolves

    // ๋ฆฌ์ŠคํŠธ๊ฐ€ 1 ์ดํ•˜์ธ ๊ฒฝ์šฐ ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜
    If Sniff length of wolves and 1 then
        Howl sorted_wolves as Den
        Mark sorted_wolves with wolves
        Pack learned quick_sort
    Pack decides

    // ํ”ผ๋ฒ— ์„ ํƒ: ์ฒซ ๋ฒˆ์งธ ๋Š‘๋Œ€๋ฅผ ํ”ผ๋ฒ—์œผ๋กœ ์‚ฌ์šฉ
    Howl pivot as Den
    Mark pivot with wolves[0]

    // ํ”ผ๋ฒ—์„ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ
    Howl less as Den
    Howl greater as Den
    For each wolf in wolves do
        If Sniff wolf.age and pivot.age then
            Howl "๋‚˜์ด ์ ์Œ: " wolf.name
            Mark less with Fetch less and wolf
        else
            Howl "๋‚˜์ด ๋งŽ์Œ ๋˜๋Š” ๊ฐ™์Œ: " wolf.name
            Mark greater with Fetch greater and wolf
        Pack decides
    Pack moves on

    // ์žฌ๊ท€์ ์œผ๋กœ ์ •๋ ฌ ๋ฐ ํ•ฉ์น˜๊ธฐ
    Howl sorted_less as Den
    Howl sorted_greater as Den
    Mark sorted_less with Do quick_sort(less)
    Mark sorted_greater with Do quick_sort(greater)

    Howl sorted_wolves as Den
    Mark sorted_wolves with Fetch sorted_less and [pivot] and sorted_greater

    Howl "์ •๋ ฌ๋œ ๋Š‘๋Œ€ ๋ฌด๋ฆฌ: " sorted_wolves
Pack learned quick_sort

// ์ •๋ ฌ ์‹คํ–‰
Howl sorted_pack as Den
Mark sorted_pack with Do quick_sort(wolf_pack)
Howl "์ตœ์ข… ์ •๋ ฌ ๊ฒฐ๊ณผ: " sorted_pack

Pack dispersing

About

WolfCode is a playful, wolf-themed programming language designed to teach basic programming concepts. It uses wolf pack terminology to represent various programming constructs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published