Write a function named setAlarm which receives two parameters. The first parameter, employed, is true whenever you are employed and the second para...
For further actions, you may consider blocking this person and/or reporting abuse
How about prolog?
A file with one fact should do it...
To run..
Prolog still scares me . . . not its syntax, but seemingly untapped potential.
I'm sorry, but it seems like you've lost the challenge somewhere.
At first I thought I've probably missed something, but then I saw the comments and realized it wasn't me, it was whoever came up with this challenge.
If I may offer a twist - Do it in a language you've never worked with before.
I'll take Scala for a ride on this one:
Nope, sorry, still too easy.
Java
Python with optional typing indicators and tests
x86-64 assembly (NASM syntax):
Elm
Explainations
This will expose our only function
setAlarm
to the outside world (used in our tests, see below).This will define a function named
setAlarm
. It takes three parameters. Which are all three booleans.We wrap our two parameters into a tuple. That way we can easily work with pattern matching.
Tests
crackin' out the ol' Clojure 🤔
don'ttest me 😗at least with named non-positional parameters . . .
. . . there's less confusion about how silly this is 😂
My solution in js
No prior experience in Python just wanted to give it a try. Like it :) Going to spend more time on the docs in the coming days.
My solution in Python
in Gwion.
Using the newly implemented pattern matching ability.
I should implement implicit casting from bool to int and vice-versa.
EDIT: done and working.
BONUS:
!
operator as boolean, which hopefully makes more senseSolved On Purescript
Javascript:
Elixir:
JS:
Haskell
In go:
Go Playground example
c++
In C#
Public bool setalarm(bool employed = false, bool vacation = false){
return !vacation && employed;
}
nicer with some formatting:
Interresting of you use
vacation
first and your use of default values 😄